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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:15:25+00:00 2026-05-31T18:15:25+00:00

I have one tabview which contain two different tab(subject and chapter) and i need

  • 0

I have one tabview which contain two different tab(subject and chapter) and i need to
create different menu for different tab. My question is that how to create different menu
for Subject tab and chapter tab. I create two menu but it show one menu on both tab view.
Please give some hint or reference.
Thanks in Advance.
Here is my code for reference.

public class MasterMainActivity extends TabActivity
{
LayoutInflater layoutInflater = null;
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.master);
     Intent intent=getIntent();
     setResult(RESULT_OK, intent);
        layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        TabHost tabHost = getTabHost();


        TabHost.TabSpec tab1spec = tabHost.newTabSpec("tabOneSpec");        
        ImageView imgView = new ImageView(this);
        //imgView.setBackgroundResource(R.drawable.examstudy);
        tab1spec.setIndicator("Subject", imgView.getBackground());
        tab1spec.setContent(new TabContentLayout());

        TabHost.TabSpec tab2spec = tabHost.newTabSpec("tabTwoSpec");
        tab2spec.setContent(new TabContentLayout());
        ImageView imgView1 = new ImageView(this);
       // imgView1.setBackgroundResource(R.drawable.datetime);
        tab2spec.setIndicator("Chapter", imgView1.getBackground());   
        tabHost.addTab(tab1spec);
        tabHost.addTab(tab2spec);          
      }
            private class TabContentLayout implements TabHost.TabContentFactory {
        @Override
        public View createTabContent(String tag) {
            View view = null;
            if(tag.equals("tabOneSpec"))
            {
                view = (LinearLayout) layoutInflater.inflate(R.layout.subjecttabview, null);                    

            }
            if(tag.equals("tabTwoSpec"))
            {
                view = (LinearLayout) layoutInflater.inflate(R.layout.chaptertabview, null);                    
            }               
            return view;
        }
    }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // TODO Auto-generated method stub
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.master_subject, menu);      
            return true;
        }
        @Override
        public boolean onOptionsItemSelected(MenuItem item) 
        {
                switch (item.getItemId())
                {
                case R.id.master_AddSubject: 
                      Intent intent=new   Intent(getApplication(),AddMasterSubActivity.class);
                      startActivity(intent);
                        return true;

                case R.id.master_SubjectUpdate:
                       //deleteAll();
                        return true; 
                case R.id.master_SubjectDelete:
                       //deleteAll();
                        return true; 
                  } 
                return false; //should never happen
        }

        public boolean onCreateOptionsMenu1(Menu menu) {
            // TODO Auto-generated method stub
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.master_chapter, menu);      
            return true;
        }
        public boolean onOptionsItemSelected1(MenuItem item) 
        {
                switch (item.getItemId())
                {
                case R.id.master_Chapter_AddChapter: 
                     Intent intent=new Intent(getApplication(),AddMasterChaActivity.class);
                      startActivity(intent);
                        return true;
                case R.id.master_ChapterUpdate:
                       //deleteAll();
                        return true; 
                case R.id.master_ChapterDelete:
                       //deleteAll();
                        return true; 
                  } 
                return false; //should never happen
        }

}
  • 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-31T18:15:26+00:00Added an answer on May 31, 2026 at 6:15 pm

    But first thing,In one activity we can show only one Menu.You have two useless menu in Tab Activity.

    And Second
    The Main purpose of Tab Activity is to switching between activity not just simple view

    Instead of using two menu here used in sub activity that is started by Tab Activity.I have never tried this.But should work.

    Tab Activity{

    Tab 1: activity A

    Tab 2: activity B

    }

    A{
    Show menu here
    }

    B{
    Show menu here
    }

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

Sidebar

Related Questions

Hi i have Tab activity(Chapter,subject) and database. i need to show the chapter_table content
I have one field that I need to sum lets say named items However
i have windows application in which i am constructing dataset with two datatables one
I currently have a tabview with 3 tabs. 1 tab loads an ActivityGroup which
I have one table DataDollar...and 2 columns LineNmbr & DollarAmt in that. I need
I have one iphone application in which i am adding uitableview inside uitableviewcell.in that
Have one. Fla (Flash) file that uses ActionScript 1.0. Need to have it in
I have one thread that writes results into a Queue. In another thread (GUI),
I have one hibernate sequence, that generates all sequence-numbers in my app. When I
I have one std::list<> container and these threads: One writer thread which adds elements

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.