首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在android上设置多个工具栏的菜单

在android上设置多个工具栏的菜单
EN

Stack Overflow用户
提问于 2015-06-30 10:46:07
回答 1查看 20K关注 0票数 21

在我的活动中,我为我的两个工具栏使用了以下代码。

代码语言:javascript
复制
 @Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Creating The Toolbar and setting it as the Toolbar for the activity
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("My title");

    toolbar2 = (Toolbar) findViewById(R.id.tool_bar_bottom);
    setSupportActionBar(toolbar2);
    ...
 }

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

我希望它的顶部工具栏使用menu_main.xml,底部工具栏使用menu_bottom,但顶部和底部工具栏都使用menu_main.xml。

有没有人能解释一下怎么做才对呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31128698

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档