How to create an optionsMenu in an Android's TabActivity

↘锁芯ラ 提交于 2019-12-02 08:53:46

问题


I try to create options menu in a TabActivity.

But instead of it I see for every activity within tabbar its own options menu.

Is it possible change this behaviour? And if yes, how?

Thank you


回答1:


Ok. I think I know the solution.

If there onCreateOptionsMenu in any activity within tabbar, so it should be modified a bit:

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // is activity withing a tabactivity
    if (getParent() != null) 
    {
        return getParent().onCreateOptionsMenu(menu);
    }
    ...
}


来源:https://stackoverflow.com/questions/5102662/how-to-create-an-optionsmenu-in-an-androids-tabactivity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!