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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:23:32+00:00 2026-05-23T08:23:32+00:00

I have 4 tabs in a page view when i click first time on

  • 0

I have 4 tabs in a page view when i click first time on tab it executes it oncreate() method of corresponding tab and when i go to other tab on same page and again click on previous clicked tab then its oncreate() method not execute why?why it is not work as button click means each time i click its oncreate() method run.

my code for tab activity class is below

  intent1 = new Intent().setClass(this, keywordxmlparsing.class);
spec1 = tabHost.newTabSpec("Activity2").setIndicator("keyword/ search...").setContent(intent1);
tabHost.addTab(spec1); 

intent2 = new Intent().setClass(this, filter.class);
spec2 = tabHost.newTabSpec("Activity1").setIndicator("filter search").setContent(intent2);
tabHost.addTab(spec2);
intent3 = new Intent().setClass(this, OpeningToday.class);
spec3 = tabHost.newTabSpec("Activity3").setIndicator("opening today").setContent(intent3);
tabHost.addTab(spec3);
intent4 = new Intent(keywordresulttab.this,Map.class);
spec4 = tabHost.newTabSpec("Activity4").setIndicator("Map").setContent(intent4);
tabHost.addTab(spec4);

dear if i use

    @Override
public void onTabChanged(String label) {
    // TODO Auto-generated method stub
    if(label == "Activity2") {




    }
    try{
    if(label == "Activity4") {
        Intent intent4; 
        intent4 = new Intent(keywordresulttab.this,Map.class);
        startActivity(intent4);
        Log.i("suiuawhd","maps class");




                }

then can i go to other activity means using

  intent4 = new Intent(keywordresulttab.this,Map.class);
            startActivity(intent4);

we can load again activity on tab click??then what to written in place of

     tabHost.addTab(spec3);
intent4 = new Intent(keywordresulttab.this,Map.class);
spec4 = tabHost.newTabSpec("Activity4").setIndicator("Map").setContent(intent4);
tabHost.addTab(spec4);
  • 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-23T08:23:33+00:00Added an answer on May 23, 2026 at 8:23 am

    Tabs that contain activities are implemented by means of ActivityGroup. When someone changes a tab, corresponding activity is created only if necessary. When you move to any tab for the second time, the activity is already existing and only its window is shown.
    You should use instead:

    TabHost.setOnTabChangedListener(TabHost.OnTabChangeListener l)
    

    TabActivity with separate activities as a content are a little bit tricky so maybe you should consider using Views instead. If not you can use the following code to access all activities from each other:

    get instances of content activities from TabActivity:

    TabActivity.getLocalActivityManager().getActivity(String name)
    

    where name is given in newTabSpec() method.

    get instance of TabActivity from content activities:

    FirstTab.getParent()
    

    Using these method you can create communication between all activities (using proper casting). For example:

    public void onTabChanged(String label) {
    
      if(label.equals("Activity2")) {
          SecondActivity sa = (SecondActivity) getLocalActivityManager().getActivity(label);
          sa.modifySomething();
      }
    }
    

    If you want to change activities under tabs you should use:

    tabHost.clearAllTabs ()
    

    and create all TabSpecs once again.

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

Sidebar

Related Questions

I have several tabs in my application, and each tab loads a different sub-page
What i have is a tabbed page with 12 tabs (every tab is a
I have a tabbed application with 3 tabs The first tab is a table
I have a master page with tabs. The tabs are defined by the following
I have a page with two tabs that I want to be able to
I have a page that is using jQuery tabs. Within one of my tabs
I have an aspx page on which I have 2 static jquery tabs.Upon clicking
I have an ajax toolkit TabContainer control on my page with a couple tabs.
I have designed a tabbed page. I'm able to load forms in the tabs
I have three tabs. When I press the tab button on the bottom, is

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.