Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3977986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:59:23+00:00 2026-05-20T04:59:23+00:00

I have a ListActivity class, and when any item on the list is clicked,

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:59:23+00:00Added an answer on May 20, 2026 at 4:59 am

    Dialogs needs to be explicitly removed by programmer (or close by user). So, it should be done in this way:

    in Activity A (calling activity)

    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){
            // Do heavy weight work
    
            // Activity prepared to fire
    
            progDialog.dismiss();
        };
        thread.start();
    }
    

    Although in most use case, the heavy work should be on the callee Activity. In case, the heavy work is done onCreate of the callee, it should be like:

    Activity B (Callee):

    onCreate(){
        progDialog.show(this, "Showing Data..", "please wait", true, false);
    
        Thread thread = new Thread(this){
            // Do heavy weight work
    
            // UI ready
    
            progDialog.dismiss();
        };
        thread.start();
    }
    

    Anyway, the idea is still the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity that extends ListActivity and implementsOnScrollListener: public class RecentItemsList extends GenericListActivity
my class extends Activity, not ListActivity. i have this code on create method but
Currently I have a class that is extending the ListActivity class. I need to
I have a class defined as public class viewGroups extends ListActivity Somewhere in the
I have an Android app with a ListActivity in the main view. The list
I have a problem my ListActivity . I have this xml: <LinearLayout> <ListView android:id=@android:id/list
I have a piece of code public class Radio_groupActivity extends ListActivity { TextView selection;
I have one activity/java file (Browsefile.java) that would obtain the absolute path of the
I have a ListActivity which should call an edit form, much like in the
I have the following XML layout for a ListActivity. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.