操作栏未与 AppCompat 一起显示 [英] Actionbar not shown with AppCompat

查看:31
本文介绍了操作栏未与 AppCompat 一起显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AppCompat 将我的应用程序向后移植到 API7,但操作栏出现问题.

I am backporting my app to API7 with AppCompat and have a problem with the actionbar.

当我使用 FragmentActivity 时,操作栏会显示在我的手机 (API18) 上,但使用 ActionBarActivity 时,它会通过按下菜单按钮显示为选项菜单.

When I use FragmentActivity the actionbar is shown on my phone (API18), but with ActionBarActivity it shows up as the optionmenu by pressing the menubutton.

在带有 API7 的模拟器上,操作栏始终显示为选项菜单.

On the emulator with API7 the actionbar is always shown as an optionsmenu.

有什么想法吗?

推荐答案

为您的菜单项使用兼容命名空间,如下所示:

Use the compat name space for your menu items like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:compat="http://schemas.android.com/apk/res-auto" >
    <item android:id="@+id/action_whatever"
      android:icon="@drawable/ic_action_whatever"
      android:title="@string/whatever"
      compat:showAsAction="ifRoom"  />
</menu>

这篇关于操作栏未与 AppCompat 一起显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆