没能获得溢出功能的动作条中的android [英] Not able to get the overflow feature for actionbar in android

查看:133
本文介绍了没能获得溢出功能的动作条中的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code ::

actionbar_sort_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/searchID"
        android:icon="@drawable/ic_action_search"
        android:showAsAction="ifRoom|withText"
        android:title="Search"/>
    <item
        android:id="@+id/featuredID"
        android:icon="@drawable/ic_action_featured"
        android:showAsAction="ifRoom|withText"
        android:title="Featured"/>
    <item
        android:id="@+id/dealsID"
        android:icon="@drawable/ic_action_deal"
        android:showAsAction="ifRoom|withText"
        android:title="Deals"
        />
    <item
        android:id="@+id/inviteID"
        android:icon="@drawable/ic_action_share"
        android:showAsAction="ifRoom|withText"
        android:title="Invite or Share"/>

</menu>

清单code ::

<application
        android:name="com.myApp.utilities.AppController"
        android:configChanges="orientation|keyboardHidden"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

主题我使用 ::

android:Theme.Holo

支持库 ::

android-support-v4.jar


{编辑}

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
   xmlns:yourapp="http://schemas.android.com/apk/res-auto"  >

    <item
        android:id="@+id/searchID"
        android:icon="@drawable/ic_action_search"
        yourapp:showAsAction="never"
        android:title="Search"/>
    <item
        android:id="@+id/featuredID"
        android:icon="@drawable/ic_action_featured"
        yourapp:showAsAction="never"
        android:title="Featured"/>
    <item
        android:id="@+id/dealsID"
        android:icon="@drawable/ic_action_deal"
        yourapp:showAsAction="never"
        android:title="Deals"
        />
    <item
        android:id="@+id/inviteID"
        android:icon="@drawable/ic_action_share"
        yourapp:showAsAction="never"
        android:title="Invite or Share"/>

</menu>

错误我收到

没有在包中com.myApp发现属性showAsAction'资源标识符

No resource identifier found for attribute 'showAsAction' in package com.myApp

推荐答案

由于您使用的是你需要有自己的名称空间preFIX支持库

Since you are using Support library you need to have your own namespace prefix

 <menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:yourapp="http://schemas.android.com/apk/res-auto" >

然后改变这

  android:showAsAction="ifRoom|withText"

  yourapp:showAsAction="ifRoom|withText"

注:如果没有足够的空间显示在动作条的项目将出现在溢出菜单。如果你有空间,一些项目也出现在动作条,其余的溢出。

Note : If there is not enough space to display items in the actionbar it will appear in the overflow menu. If you have room for few items it appears on the actionbar and the rest in overflow.

编辑:

yourapp:showAsAction="never" 

从文档

http://developer.android.com/guide/topics/资源/菜单resource.html

 never  Never place this item in the Action Bar.   

这篇关于没能获得溢出功能的动作条中的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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