Activites and Intents – Part 3

This is the third lesson in our series of Activities And Intents … Now we will learn how to make a Progress Dialog … A progress dialog is useful for showing the progress of some activities, such as the status of a download operation.

The first thing we will create a button in our main.xml as we do in the previous tutorial …

As we do before we will go to our .java class and override onCreateDialog() method that will be called when we call showDialog(int id) method. Create an instance of the ProgressDialog class and set its various properties, such as icon, title, and style. And set the two buttons Hide and Cancel.

Then we go to onCreate() method and connect our button in .xml  with our button in .java code .. and then implement the function that when button pressed is fired .. and inside it we will call showDialog(int id) method and give the dialog a unique id. To display the progress status in the progress dialog, you need to use a Handler object to run a background thread

The background thread counts up to 100, with each count delayed by 100 milliseconds. When the count reaches 100, the progress dialog is dismissed.

Now Run your program .. and see your great result .. tadaaaaaa 😀

That’s all for now .. and sorry for my delay in publishing this lesson 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s