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

  • Home
  • SEARCH
  • 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 6240225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:31:43+00:00 2026-05-24T11:31:43+00:00

I am trying to put progress dialog on Click event of ListView as mentioned

  • 0

I am trying to put progress dialog on Click event of ListView as mentioned in code below but I am getting error “WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@44eddc70 is not valid; is your activity running?” can you give me any solution for this ?

code

 final ListView lv1 = (ListView) findViewById(R.id.list);
    lv1.setAdapter(new EfficientAdapter(this));

    lv1.setTextFilterEnabled(true);

    lv1.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> a, View v,
                final int position, long id) {
            final ProgressDialog pd = ProgressDialog.show(Add_Entry.this,
                    "", "Please Wait....");
            new Thread() {
                public void run() {

                    if (lv1.getItemAtPosition(position).equals(0)) {

                        Intent edit = new Intent(getApplicationContext(),
                                SourceOfStress.class);
                        TabGroupActivity parentActivity = (TabGroupActivity) getParent();
                        edit.putExtra("currActi", "AddEntry");
                        parentActivity.startChildActivity("SorceOfStress",
                                edit);

                    }
                    if (lv1.getItemAtPosition(position).equals(1)) {
                        Intent edit = new Intent(getParent(),
                                SourceOFSymptoms.class);
                        TabGroupActivity parentActivity = (TabGroupActivity) getParent();
                        edit.putExtra("currActi", "AddEntry");
                        parentActivity.startChildActivity(
                                "SourceOFSymptoms", edit);
                    }
                    if (lv1.getItemAtPosition(position).equals(2)) {
                        Intent edit = new Intent(getParent(),
                                Stress_Resilliance.class);
                        TabGroupActivity parentActivity = (TabGroupActivity) getParent();
                        edit.putExtra("currActi", "AddEntry");
                        parentActivity.startChildActivity(
                                "Stress_Resilliance", edit);
                    }
                    pd.dismiss();
                }
            }.start();
        }

    });

My file name is Add_Entry.java
and error comes in line

ProgressDialog.show(Add_Entry.this,
                    "", "Please Wait....");
  • 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-24T11:31:44+00:00Added an answer on May 24, 2026 at 11:31 am

    You are trying to update the UI from a thread. You can’t do that.

    Use the Handler mechanism to update UI components.

    Code taken from the website : Here the Handler class is used to update a ProgressBar view in a background Thread.

    package de.vogella.android.handler;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.View;
    import android.widget.ProgressBar;
    import android.widget.TextView;
    
    public class ProgressTestActivity extends Activity {
      private Handler handler;
      private ProgressBar progress;
      private TextView text;
    
    
    /** Called when the activity is first created. */
    
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        progress = (ProgressBar) findViewById(R.id.progressBar1);
        text = (TextView) findViewById(R.id.textView1);
    
      }
    
      public void startProgress(View view) {
        // Do something long
        Runnable runnable = new Runnable() {
          @Override
          public void run() {
            for (int i = 0; i <= 10; i++) {
              final int value = i;
              try {
                Thread.sleep(2000);
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
              progress.post(new Runnable() {
                @Override
                public void run() {
                  text.setText("Updating");
                  progress.setProgress(value);
                }
              });
            }
          }
        };
        new Thread(runnable).start();
      }
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to put a ProgressBar view below a ListView for a ListActivity. I
i am trying to intergrate the jquery progress bar but i am getting issues.
I am trying to create an update query and making little progress in getting
I'm trying to put a progress on my file copy form, got that to
I'm trying to modified a code to do something a bit different but I
Hi I am new in android and I am trying to put process Dialog
Hi I am new to Android and trying to put process dialog on List
I'm trying to show a progress dialog while loading information from the web that
I'm trying put an if statement directly into a select field in rails, with
Trying to put a regex expression together that returns the string between _ and

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.