我使用支持库中的 ActionBar 在 3.0 之前的设备上包含操作栏。
但问题是,没有显示操作栏(使用 API 10 - 在模拟器上)。
在 Android 4.2 上可以使用。
我在我的 list 中设置了这个:
android:theme="@style/Theme.Base.AppCompat.Light.DarkActionBar"
我的 styles.xml 看起来像这样:
<style name="AppBaseTheme" parent="Theme.Base.AppCompat.Light.DarkActionBar"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backward-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> </style>
所有功能都有效。但是没有操作栏。 :( 我认为这是一个 Style 问题,因为代码中没有异常。
最佳答案
虽然您的主题看起来正确(尽管大多数人更愿意使用 Theme.AppCompat.Light.DarkActionBar
以实现平台独立性和在所有设备上的一致外观),但根据 Adding an Action Bar guide您还必须确保您的 Activity 扩展 ActionBarActivity
,而不是 Activity
或 FragmentActivity
。
关于Android - API 10 没有 ActionBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18855790/