开发者

How to create an optionsMenu in an Android's TabActivity

开发者 https://www.devze.com 2023-02-13 07:21 出处:网络
I try to create options menu in a TabActivity. But instead of it I see for every activity within tabbar its own options menu.

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 yo开发者_开发百科u


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);
    }
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消