操作栏选项菜单列表未显示

时间:2015-04-20 05:26:05

标签: android menu options

我创建了一个包含操作栏标签和选项菜单的应用。我能够获取选项卡但无法在操作栏的边缘看到操作栏选项菜单列表。不确定原因是什么?请帮忙

main activity.java

actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); 
        actionBar.setDisplayHomeAsUpEnabled(true);
        setTitle("Records");



actionBar.addTab(actionBar.newTab()
                .setText("Documents & Records")
                .setTabListener(new TabListener<Records>(this, "Records", Records.class)));

actionBar.addTab(actionBar.newTab()
                .setText("Promotions")
                .setTabListener(new TabListener<Promotions>(this, "Promotions", Promotions.class)));

actionBar.addTab(actionBar.newTab()
                .setText("Messages")
                .setTabListener(new TabListener<Messages>(this, "Messages", Messages.class))); 



 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
     switch(item.getItemId()){
        case R.id.action_settings1:
        startActivity(new Intent(MenuPage.this, About_Us.class));
        return true;

        default:
        return super.onOptionsItemSelected(item); 
     }
 }

menu.xml文件

 <item
         android:id="@+id/action_settings1"
         android:orderInCategory="1"
         android:showAsAction="never"
         android:title="@string/action_settings1"/>

3 个答案:

答案 0 :(得分:0)

删除android:showAsAction =&#34; never&#34;来自xml文件或总是而不是永远

答案 1 :(得分:0)

尝试包含以下代码:

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

答案 2 :(得分:0)

非常感谢,加入以下工作

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