-1

I make a tabactivity:

public class VisitShopMenuTab extends TabActivity{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.visit_shop_menu_tab);

        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);

        for (int i = 0; i < 5; i++) {
            TabSpec tab = tabHost.newTabSpec("tab"+i);
            tab.setIndicator("  Tab-"+i+"  ").setContent(new Intent(this,VisitShopMenu.class));
            tabHost.addTab(tab);
        }  
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.visit_shop_menu_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.visit_shop_menu_menu_close:
            finish();
            return true;
        case R.id.visit_shop_menu_menu_printing:
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
}

My problem: When I push the MENU button on the emulator, the Menu doesn't appear. But when I use this menu methods in another Class (Just a simple Activity) the menu appear.

Cœur
  • 37,241
  • 25
  • 195
  • 267
BaluEdo
  • 119
  • 2
  • 11
  • possible duplicate of [How to create an optionsMenu in an Android's TabActivity](http://stackoverflow.com/questions/5102662/how-to-create-an-optionsmenu-in-an-androids-tabactivity) – Peter Knego Mar 15 '11 at 21:10
  • This problem not a problem. This is my mistake. My friend write the onKeyDown in the VistiShopMenu, and when I tryed to appear a menu, my friend method runnin first. Thanks everyone, who read the topic and try to help me. But this is my inattantion. – BaluEdo Mar 15 '11 at 21:40

3 Answers3

0

Look at this: How to create an optionsMenu in an Android's TabActivity

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
0

Have you tried putting your menu code in the VisitShopMenu activity?

Damp
  • 3,328
  • 20
  • 19
  • Yes I try it, but don't appear it. And I have place any Log in the menu methods, but don't running this method. – BaluEdo Mar 15 '11 at 21:20
0

cut paste the code of menu options in visitshopmenu activity. it will run there...

Farhan
  • 13,290
  • 2
  • 33
  • 59