Top Menu

I have a main activity that has simple buttons and listeners associated with them. Each button opens a new activity . However while opening activity, it takes some time to load which causes a UI freeze. I want to avoid this by simply adding a loading circle in between.
That is a Progress Bar. You may create this programmatically or by using the widget in XML.
To implement in XML:

<ProgressBar
    android:id="@+id/progress_loader"
    style="?android:attr/progressBarStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:visibility="visible" />
To implement in Java (using a Progress Dialog as you asked in comments, but you can also do this with the
Progress Bar):
ProgressDialog nDialog;
 nDialog = new ProgressDialog(Login.this);
 nDialog.setMessage("Loading..");
 nDialog.setTitle("Get Data");
 nDialog.setIndeterminate(false);
 nDialog.setCancelable(true);
 nDialog.show();
Before reaching the next activity, you should dismiss() the Progress Bar.

 nDialog.dismiss();

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Close