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 6995469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:01:47+00:00 2026-05-27T20:01:47+00:00

final ProgressDialog Pdialog = ProgressDialog.show(SpinnerClass.this, , Loading. Please wait…, true); Thread ProgressThread = new

  • 0
   final ProgressDialog Pdialog = ProgressDialog.show(SpinnerClass.this, "", 
                        "Loading. Please wait...", true);
                Thread ProgressThread = new Thread() {
                    @Override
                    public void run() {
                        try {
                                     sleep(3000);   
                                     Pdialog.dismiss();

                        } catch(InterruptedException e) {
                            // do nothing
                        } finally {

                        }
                    }
                };
                ProgressThread.start();
                TabHost1 TabHost1Object2 = new TabHost1();
                TabHost1Object2.tabHost.setCurrentTab(2);

The problem I have with this thread is that it sets the current tab before the progress dialog starts. What have i done wrong ?
I want the dialog to run and dismiss, and after thread is done set tab.

  • 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-27T20:01:48+00:00Added an answer on May 27, 2026 at 8:01 pm

    The thing is that,you are starting a thread which will not affect your main UI. So what eventually happens is that, your thread will run separately which will now allow the next lines of your code to be executed. So in your case,

                TabHost1 TabHost1Object2 = new TabHost1();
                TabHost1Object2.tabHost.setCurrentTab(2);
    

    these lines will be executed irrespective to your thread which is also getting executed simultaneously. So what you can do here is you can either go for AsyncTask or create handlers to handle this part of your code. You have to change your code like this.

    Do this in your onCreate()

               Handler handler;
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == 0) {
             Pdialog.dismiss();     
                 TabHost1 TabHost1Object2 = new TabHost1();
                TabHost1Object2.tabHost.setCurrentTab(2);
    
             }
           };
    

    And now in your thread,call the handler like this,

      final ProgressDialog Pdialog = ProgressDialog.show(SpinnerClass.this, "", 
                        "Loading. Please wait...", true);
                Thread ProgressThread = new Thread() {
                    @Override
                    public void run() {
                        try {
                                     sleep(3000);   
    
    
                        } catch(InterruptedException e) {
                            // do nothing
                        } finally {
    
                                 handler.sendEmptyMessage(0);
                        }
                    }
                };
    this will allow your tabhost to wait until the thread gets executed and will come into view after thread finishes execution. 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code: final ProgressDialog pd = ProgressDialog.show(Main.this,,Loading. Please wait..., true); pd.show(); Thread t = new
private class ExecuteLocations extends AsyncTask<String, Void, Void>{ private final ProgressDialog dialog = new ProgressDialog(ListProfiles.this);
i want to show spinning wheel progress but it doesn't show anything. final ProgressDialog
mycontext.startActivity(new Intent(mycontext, logoSplash.class)); //this finishes after 3 seconds: initcontrols(); final Timer timerStartAll = new
Final question for the night. And apologies for the complete noobness of this. I
public static Logger getLogger() { final Throwable t = new Throwable(); final StackTraceElement methodCaller
So the final menu will look something like this: Item B Item B-1 Item
i got some problem to show correctly a ProgressDialog during an image upload. I've
Possible Duplicate: Android: ProgressDialog.show() crashes with getApplicationContext I want to have a progress dialog
I get this error Can't create handler inside thread that has not called Looper.prepare()

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.