Android loading circle between two activity
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:
[code inline=”false” scrollable=”true”]
<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" />
[/code]
To implement in Java (using a Progress Dialog as you asked in comments, but you can also do this with the
Progress Bar):
[code inline=”false” scrollable=”true”]
ProgressDialog nDialog;
nDialog = new ProgressDialog(Login.this);
nDialog.setMessage("Loading..");
nDialog.setTitle("Get Data");
nDialog.setIndeterminate(false);
nDialog.setCancelable(true);
nDialog.show();
[/code]
Before reaching the next activity, you should dismiss() the Progress Bar.
nDialog.dismiss();