I want to create such a dialog to show progress bar like I have attached. I want to show some sequence of pictures while some work is doing in background and progress bar is showing to the user. How can I make such a activity/dialog? Can anyone advice me something?
-
1This example look similar to what you want to do: [here](http://huuah.com/android-progress-bar-and-thread-updating/) . Got it from this thread [thread](http://stackoverflow.com/questions/4581812/custom-progress-bar-in-android) – Eri Nov 22 '12 at 16:32
2 Answers
What's exactly your problem? The layout or the code that shows the different images depending on the progress?
I guess its not the layout. So I would recommend you to use a Runnable / AsyncTask with a Handler. See the AsyncTask Reference for this.
So the main idea would be: Start a dialog in your Main Activity and a Runnable which receives a Handler from your main activity. The Runnable itself extends AsyncTask and does something in the "doInBackground" function for example sending messages to your progress dialog through the Handler.sendMessage(msg) function, your main class can receive this messages through the "handleMessage" function and update the image depending on the message received. That's maybe no the most precise explanation, but the links above should make it clear.

- 35,075
- 22
- 89
- 84
Utilize the ProgressBar ui element.
http://developer.android.com/reference/android/widget/ProgressBar.html
Your layout would look something like below.
<LinearLayout
android:orientation="horizontal"
... >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
..... />
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_marginRight="5dp" />
</LinearLayout>
Then in your activity, while your updating the progress bar in the "onProgressUpdate" of an AsyncTask you can also switch out the image in the imageView, on some kind of interval.

- 294
- 1
- 7