操作栏未与 AppCompat 一起显示

编程入门 行业动态 更新时间:2024-10-25 06:25:42
本文介绍了操作栏未与 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="schemas.android/apk/res/android" xmlns:compat="schemas.android/apk/res-auto" > <item android:id="@+id/action_whatever" android:icon="@drawable/ic_action_whatever" android:title="@string/whatever" compat:showAsAction="ifRoom" /> </menu>

更多推荐

操作栏未与 AppCompat 一起显示

本文发布于:2023-10-09 18:07:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   AppCompat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!