我正在尝试让我的选项显示在标题栏中。我正在使用 ActionBarSherlock,我可以弄清楚如何删除标题栏中的标题,但想用我的选项菜单中的 2 个选项替换文本。
我正在使用此代码,EmpubLite作为我的应用程序的示例,但我无法弄清楚 Mark(commonsware 人)如何从标题栏的选项菜单中获取图标。我的选项显示在操作栏的底部,这会占用屏幕上不必要的空间。我一直在查看此处的示例,但似乎无法确切了解如何在标题栏中获取选项。我希望马克(或其他人)能解释一下。
最佳答案
would like to replace the text with 2 options from my options menu
嗯,除非通过删除标题自动发生这种情况,否则我怀疑这是不可能的。
but I can't figure out how Mark (the commonsware guy) got the icons from his options menu in the title bar
嗯,你看,这在 this delightful little book 中有介绍。 ...:-)
更严重的是,android:showAsAction
控制项目是否应该在溢出区域(never
),是否应该在操作栏(ifRoom
) >),或者真的真的应该在操作栏中 (always
)。话虽这么说,始终
是一个提示,而不是一个要求,并且操作系统可能仍会在较小的屏幕尺寸上将您的操作栏项目放在溢出中。
您没有说明您正在试验的是哪个 EmPubLite 系列。早期,项目都设置为 never
:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/help"
android:icon="@android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="@string/help"/>
<item
android:id="@+id/about"
android:icon="@android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="@string/about">
</item>
</menu>
在本系列结束时,我们有一些理想情况下会进入操作栏:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/notes"
android:icon="@android:drawable/ic_menu_edit"
android:showAsAction="ifRoom|withText"
android:title="@string/notes">
</item>
<item
android:id="@+id/update"
android:icon="@android:drawable/ic_menu_save"
android:showAsAction="ifRoom|withText"
android:title="@string/download_update">
</item>
<item
android:id="@+id/settings"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction="never"
android:title="@string/settings">
</item>
<item
android:id="@+id/help"
android:icon="@android:drawable/ic_menu_help"
android:showAsAction="never"
android:title="@string/help">
</item>
<item
android:id="@+id/about"
android:icon="@android:drawable/ic_menu_info_details"
android:showAsAction="never"
android:title="@string/about">
</item>
</menu>
My options show up at the bottom in the action bar and this is taking up unnecessary room on the screen.
然后,您在 list 中的某处设置了 android:uiOptions="splitActionBarWhenNarrow"
。
关于android - 如何从选项菜单中获取选项到标题栏 ActionBar Sherlock android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14468517/