0

How can i add drop menu in actionbar??

I try add always just add tab, never see drop menu.

            viewPager = (ViewPager) findViewById(R.id.view_pager);   
            actionBar = getActionBar();              
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setDisplayShowHomeEnabled(false);

            Tab tab = actionBar.newTab().setText("Page1").setTabListener(this);
            actionBar.addTab(tab);

            tab = actionBar.newTab().setText("Page2").setTabListener(this);
            actionBar.addTab(tab);

            tab = actionBar.newTab().setText("Page3").setTabListener(this);
            actionBar.addTab(tab);

            viewList = new ArrayList<View>();
            View view1 = (View) View.inflate(this, R.layout.layout1, null);
            View view2 = (View) View.inflate(this, R.layout.layout2, null);

Please see img
http://goo.gl/mLslk

user1484400
  • 119
  • 1
  • 2
  • 13
  • This answer seems similar to what you're looking for: http://stackoverflow.com/questions/8312344/how-to-add-a-dropdown-item-on-the-action-bar – Grantismo Jun 27 '13 at 15:41
  • thank Grantismo. I try it.but not in same line, ths drop menu in tap below. – user1484400 Jun 28 '13 at 07:18

1 Answers1

0

I think what you want is to use an option menu.

To do this, you must create on your menu folder which is inside res folder an xml file indicating the options you want to show.

And in your activity, you must use this method to show the options menu defined on the xml file called example.xml in this case.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.example, menu);
    return true;
}

I hope this helps.

javixanxez
  • 86
  • 6
  • Thanks javixanxez I try using u say. add onCreateOptionsMenu(Menu menu) but always to second actionbar...not like i want. like this http://goo.gl/Gt3RZ – user1484400 Jun 28 '13 at 01:41