Home > Android, Android how to > Showing ProgressDialog in Android Activity

Showing ProgressDialog in Android Activity

We moved. Please visit this link for this post.




In situations when need to wait some operation it is good practice to notify user that operation is in progress.
For this cases in Android present several classes which can help with this. One of them I am going to demonstrate.
I will show how to use ProgressDialog class for showing progress dialog. I will show how to create preogress dialog with title and without title.

There are several show methods.

I will take this one:

ProgressDialog.show(Context context, CharSequence title, CharSequence message);

In my case I write

ProgressDialog.show(Main.this, "In progress", "Loading");

Now my progress dialog shows on activity

Okay. It is working.

What if I want to hide title? It is also very easy, just put empty string as title parameter. Example:

ProgressDialog.show(Main.this, "", "Loading...");

It is working very good.
Need to stop it:


Full code, for testing my words:

import android.app.Activity;

import android.app.ProgressDialog;

import android.os.Bundle;

import android.util.Log;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;


* Class for showing how to work with progress dialog

* @author FaYna Soft Labs


public class Main extends Activity {

private Button clickBtn;

private ProgressDialog progressDialog;


public void onCreate(Bundle savedInstanceState) {



clickBtn = (Button) findViewById(R.id.click);

clickBtn.setText("Click me");

clickBtn.setOnClickListener(new OnClickListener() {


public void onClick(View v) {

//start the progress dialog

progressDialog = ProgressDialog.show(Main.this, "", "Loading...");

new Thread() {

public void run() {



} catch (Exception e) {

Log.e("tag", e.getMessage());


// dismiss the progress dialog








Progress dialog is one of UI classes which helps to notify user about long operations.

Personally I very often use this class.

Categories: Android, Android how to
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: