I want a progress circle instead of progress dialog

I want to show a progress Circle in my app while loading data. I have an activity and moving from one activity to another I am parsing some xml data so for the time being until the parsing is completed I want to show a circular loading effect.


You can use an indeterminate ProgressBar for the circular loading effect. Here is how you do it in XML:

<ProgressBar android:indeterminate="true"
            android:layout_width="50dp" android:layout_height="50dp"
            android:id="@+id/marker_progress" style="?android:attr/progressBarStyle"

You can change the height and width to be what you want. When you are done loading, you can change it's visibility to View.INVISIBLE or View.GONE

You need to create animation xml file in res/anim folder and call startAnimation in your ImageView when you are loading data and stopAnimation when you stop loading data. And set loading image to ImageView, for example:

This id code for circle animation xml file

<?xml version="1.0" encoding="UTF-8"?>
    android:interpolator="@android:anim/linear_interpolator" />

Insert this beetween two View tags

<ProgressBar android:id="@+id/loading_spinner"
        android:layout_gravity="center" />

Why not use the progressbar UI

myProgressDialog = ProgressDialog.show(ListingPage.this,"Please Wait", "Loading Date", true);


Use AsyncTask for loading and parsing:

   * Background task that fetched the content from server and parses the content.
  private class BackgroundLoadingTask extends AsyncTask<InputStream, Void, Boolean> {

    protected void onPreExecute() {
      // show the progress bar

    protected Boolean doInBackground(InputStream... params) {

      // try to load XML from HTTP server and parse

      return true;

    protected void onPostExecute(Boolean parsingError) {
      // hide the progress bar


Just as you would the progress dialog, use an animation instead with async task and just make it visible on prexecution and hide it again on post.

To expand a bit on trgraglia's answer, you could create an indeterminate (behavior: cycle) progress bar and set the visibility to false. During AsyncTask preExecute(), make it visible, and during AsyncTask onPostExecute(), turn it back to invisible (provided you are staying on the same activity or w/e case you may need). This eliminates the need to create an animation.

Need Your Help

Get number of weekdays in a given month

php calendar days weekday weekend

I want to calculate the number of weekdays days in a give month and year. Weekdays means monday to friday. How do i do it ?

Referring to a div inside a div with the same ID as another inside another

javascript html dom getelementbyid

How can I refer to a nested div by id when it has the same id as a div nested in a similarly named div