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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:40:18+00:00 2026-06-07T19:40:18+00:00

I am working on Tab layout and progress dialog. I want to show progress

  • 0

I am working on Tab layout and progress dialog. I want to show progress dialog for five sec when user comes on the tab layout and when user changes the tabs.

I used following same code to show the progress dialog in both conditions.

public class TabLayoutActivity extends TabActivity {
    ProgressDialog progressDialog;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tablayoutview);
        progressDialog = ProgressDialog.show(TabLayoutActivity.this, "",
                "Loading. Please wait...");
        new Thread() {
            public void run() {
                try {
                    Thread.sleep(5000);
                    TabHost tabHost = getTabHost();
                    TabHost.TabSpec tabSpec;
                    Intent intent = new Intent().setClass(
                            getApplicationContext(), FirstTabActivity.class);
                    tabSpec = tabHost.newTabSpec("first").setIndicator("First")
                            .setContent(intent);
                    tabHost.addTab(tabSpec);

                    intent = new Intent().setClass(getApplicationContext(),
                            SecondTabActivity.class);
                    tabSpec = tabHost.newTabSpec("second")
                            .setIndicator("Second").setContent(intent);
                    tabHost.addTab(tabSpec);
                } catch (Exception e) {
                    Log.e("tag", e.getMessage());
                }
                progressDialog.dismiss();
            }
        }.start();
    }
}

The progress dialog working fine, but contents of the tabs does not display. It is showing following error.

“Only the original thread that created a view hierarchy can touch its views”

  • 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-06-07T19:40:21+00:00Added an answer on June 7, 2026 at 7:40 pm

    try this

    public class TabLayoutActivity extends TabActivity {
    ProgressDialog progressDialog;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tablayoutview);
        progressDialog = ProgressDialog.show(TabLayoutActivity.this, "",
                "Loading. Please wait...");
        new Thread() {
            public void run() {
                try {
                    Thread.sleep(5000);
     TabLayoutActivity .this.runOnUiThread(new Runnable() {
    
        @Override
        public void run() {
            TabHost tabHost = getTabHost();
                    TabHost.TabSpec tabSpec;
                    Intent intent = new Intent().setClass(
                            getApplicationContext(), FirstTabActivity.class);
                    tabSpec = tabHost.newTabSpec("first").setIndicator("First")
                            .setContent(intent);
                    tabHost.addTab(tabSpec);
    
                    intent = new Intent().setClass(getApplicationContext(),
                            SecondTabActivity.class);
                    tabSpec = tabHost.newTabSpec("second")
                            .setIndicator("Second").setContent(intent);
                    tabHost.addTab(tabSpec);
                  progressDialog.dismiss();
        }
    });
    
                } catch (Exception e) {
                    Log.e("tag", e.getMessage());
                }
    
            }
        }.start();
    }
    

    }

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

Sidebar

Related Questions

I'm working on a tab bar application and one of the tabs has a
I am working on tab host application containing 4 tabs. Each tab has individual
I used to be able to see a working preview of what my layout
Here i make 5 Tab buttons that are working proper but now i want
So I have my tab layout working as demonstrated in the Android example :
I am working on the Andriod Tab Layout App to get use to the
I am trying to get swipe gestures working with a tab layout in an
I am working on android, i want to add tab widget to the bottom
i am working in android. I want to make TabHost and Tab widget. this
I'm working on an Android application with an activity that uses a tab layout.

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.