使用动作条的标签导航菜单时崩溃 [英] Menu collapsing when using ActionBar tabs for navigation

查看:93
本文介绍了使用动作条的标签导航菜单时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用的ActionBar从支持库来构建我的应用程序中的选项卡式导航栏。我在我的应用程序两个选项卡。这两个片段的具有菜单和它们有一个菜单项,我想它显示为在操作栏中的动作,但由于某些原因溢流显示图标,而不是分配给这些项目的图标。它们表示为在下拉菜单中的文字。

I have used ActionBar from the support library to build my application a tabbed navigation bar. I have two tabs in my application. Both of these Fragments have menus and they have one menu item and I'd like to show it as an action in the action bar, but for some reason the overflow icon is shown instead of the icons assigned to these items. They are shown as text under the dropdown menu.

我的XML看起来以下。

My XML looks the following.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/my_id"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:icon="@drawable/ic_action_new"
        android:title="New"/>
</menu>

怎么了?

推荐答案

由于您使用的是活动的兼容包,请确保您构建菜单项(的链接)。这里有一个音符从引导菜单项实施:

As you're using the activities from the compatibility package, make sure that you use the proper namespaces when building the menu item(link). Here's a note from the guide to the menu item implementation:

使用XML的支持库属性

注意的 showAsAction 属性上面使用的标签定义自定义命名空间。使用由支持库定义的XML属性时,因为这些属性在旧设备的Andr​​oid框架是不存在的,这是必要的。所以,你必须使用自己的名称空间为preFIX由支持库中定义的所有属性。

Notice that the showAsAction attribute above uses a custom namespace defined in the tag. This is necessary when using any XML attributes defined by the support library, because these attributes do not exist in the Android framework on older devices. So you must use your own namespace as a prefix for all attributes defined by the support library.

这篇关于使用动作条的标签导航菜单时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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