I have a ListActivity class, and when any item on the list is clicked, a new activity is displayed. The new activity takes time to load, so i would like the users to know that there is something happening (in the form of a progress dialog)
So, in order to do this, i implemented Runnable in my class like this -
public class ProtocolListActivity extends ListActivity implements Runnable {
private ProgressDialog progDialog;
....
protected void onListItemClick(ListView l, View v, int position, long id) {
progDialog.show(this, "Showing Data..", "please wait", true, false);
Thread thread = new Thread(this);
thread.start();
}
....
public void run() {
// some code to start new activity based on which item the user has clicked.
}
Initially, when i click, and the new activity is being loaded, the progress dialog works nicely, but when i close the previous activity (to get back to this list) the progress dialog is still running. I want the progress dialog to show up only for the time the new activity is being started.
Can someone please guide me on how to do this correctly.