SherlockFragment中的onCreateOptionsMenu未调用

时间:2014-06-17 13:02:38

标签: android actionbarsherlock oncreateoptionsmenu

我在带有ActionBar导航抽屉的SherlockFragmentActivity中有一个SherlockFragment。我想为每个片段显示不同的图标。当我运行应用程序y android 2.3.6时调用onCreateOptionsMenu方法,但是当我在android 4+中运行该应用程序时,该方法不会被调用。

任何人都可以帮助我吗?

感谢。

修改

This image is first section of an app that has that i want. Menu: dropdown, search collapsible and right sidemenu.

And this is another section of the same app with the same navigation drawer and has different menu items for each fragment.

1 个答案:

答案 0 :(得分:0)

您使用的是哪个主题?在您的清单中,尝试将您的主题更改为Theme.Black.NoTitleBar。 或者Holo

android:theme="@android:style/Theme.Black.NoTitleBar"

选项菜单不适用于更高版本。 在API 11之前,没有操作栏。 ActionBar Sherlock允许您使用Android设备上的操作栏,或者您可以在项目中使用支持库v7来使用操作栏。 有Action类作为以后的android版本的标准解决方案。您可以阅读这个适用于Android 4.0+设备的ActionBar教程。

相关问题