ActionBar items not showing up using FragmentTabs

2019-06-05 22:52发布

I'm using ActionBarSherlock and have a little problem. In the Fragment Tabs example, there are four tabs. Three of them add items to the ActionBar, but the first one doesn't (Labeled "Simple"). I'm trying to get that first one to add an item to the ActionBar, but it doesn't work for some reason. The only difference I can see between the tabs is that the "Simple" one is a SherlockFragment, and the other three are SherlockListFragments.

The SherlockListFragments use the onCreateOptionsMenu as usual to populate the ActionBar, but when I add that to the SherlockFragment and trace it, it doesn't even get called and no items appear on the bar.

Can I not add ActionBar items with a SherlockFragment?

1条回答
闹够了就滚
2楼-- · 2019-06-05 23:33

Did you call setHasOptionsMenu(true)?

查看更多
登录 后发表回答