Skip to main content

Posts

Showing posts with the label Activities

Showing a Progress Dialog

     One normal UI highlight in an Android gadget is the "Please wait" exchange that you ordinarily observe when an application is playing out a long-running errand. For instance, the application may be signing in to a worker before the client is permitted to utilize it, or it very well may be doing a computation prior to showing the outcome to the client. In such cases, it is useful to show a discourse, known as a progress dialog , with the goal that the client is kept on top of it.   Displaying a Progress Dialog (Please Wait):-   1.Manifest File <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.jfdimarzio.activity101">      <application          android:allowBackup="true"           android:icon="@mipmap/ic_launcher"       ...

Displaying a Dialog Window

There are times when you need to display a dialog window to get a confirmation from the user. In this case , you can override the onCreateDialog() protected method defined in the Activity base class to display a dialog window. The following Try It Out shows you how. 1. Using Android Studio , create a new Android project and name it Dialog. When presented with the option , name the main activity DialogActivity. 2.Add the following theme in bold to the AndroidMainfest.xml file. Be sure to change all instances of "com.android" to whatever package name your project is using. <?xml version="1.0" encoding="utd-8"?> <manifest xmlns:android"http://schemas.android.com/apk/res/android" package="com.android.dialog">      <application           android:allowBackup="true"           android:icon:="@mipmap/ic_launcher"         ...

Hiding the Activity Title

You can also hide the title of an activity if desired ( Such as when you just want to display a status update to the user). To do so , use the requestWindowFeature() method and pass it the window .FEATURE_NO_TITLE constant, like This : import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; public class MainActivity extends AppCompatActivity{            @Override            protected void onCreate ( Bundle savedInstanceState )            {                         super.onCreate (savedInstanceState );                         setContentView (R.layout.activit...

Understanding Activities

This blog begins by showing you to create an activity. To create an activity , you create a Java class that extends the Activity base class : public class MainActivity extends AppcompatActivity {           @Override           protected void onCreate(Bundle savedInstanceState)           {                     super.onCreate(savedInstanceState);                     setContentView(R.laout.activity_main);           } } Your activity class loads its user interface ( UI ) component using the XML file defined in your res/layout folder . In this example , you would load the UI from the main.xml file :   ...