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