How to create an optionsMenu in an Android's TabActivity

前端 未结 1 1083
渐次进展
渐次进展 2021-01-25 15:40

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 behaviou

相关标签:
1条回答
  • 2021-01-25 16:12

    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 讨论(0)
提交回复
热议问题