在我的活动中,我为我的两个工具栏使用了以下代码。
@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。
有没有人能解释一下怎么做才对呢?
https://stackoverflow.com/questions/31128698
复制相似问题