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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:19:16+00:00 2026-06-17T20:19:16+00:00

I have many tabs like this: TabHost th; TabSpec spec; th = (TabHost) findViewById(R.id.tabhost_template_two_tabs);

  • 0

I have many tabs like this:

TabHost th;
TabSpec spec;
th = (TabHost) findViewById(R.id.tabhost_template_two_tabs);
th.setup();
// all tab
spec = th.newTabSpec("All");
spec.setIndicator("All");
spec.setContent(R.id.tab_template_two_tabs_all);
th.addTab(spec);
// favorite tab
spec = th.newTabSpec("Favorite");
spec.setIndicator("Favorite");
spec.setContent(R.id.tab_template_two_tabs_favorite);
th.addTab(spec);

and for each tab i want to add a menu, how please?

  • 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-17T20:19:17+00:00Added an answer on June 17, 2026 at 8:19 pm

    Each Tabin the TabHost has a number starting from 0, so you have to know which tab you are in now by using int currentTab = th.getCurrentTab(); and then clear the previous menu by using menu.clear() then adding your new menu by using inflater.inflater(menuID, menu)

    @Override
        public boolean onPrepareOptionsMenu(Menu menu) {
            // TODO Auto-generated method stub
            MenuInflater inflater = getMenuInflater();
            int currentTab = th.getCurrentTab();
            Toast.makeText(getApplicationContext(), currentTab+"", Toast.LENGTH_SHORT);
            if (currentTab == 0){
                menu.clear();
                inflater.inflate(R.menu.first, menu);}
            else{
                menu.clear();
                inflater.inflate(R.menu.second, menu);}
            return super.onPrepareOptionsMenu(menu);
        }
    

    note:

    onCreateOptionsMenu will not help you in your case

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

Sidebar

Related Questions

i have a site, with many tabs , when i open any tab i
I have a tab container, where i can add many tabs with long captions.
i'm trying to do something like this: tabs.addTab(new Tab(Test1) { public override void OnGUI()
I have a php page. This has multiple images which looks like tabs. With
The scenario is like this. I have a rich:tabPanel with about 5 tabs. On
I have a page where there will be many tabs and i want to
I have many tabs in tabcontainer on my asp page. I want to set
I have this Win32 user-drawn tab control that is created as: CONTROL Tab1,IDC_TAB_CONT,SysTabControl32,TCS_BOTTOM |
I have been able to disable tabs in a tab bar using the following
I have idea to implement my wpf windows like TabPages in tab control. It

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.