actionlayout的菜单项什么都不做 [英] actionlayout on menuitem does nothing

查看:210
本文介绍了actionlayout的菜单项什么都不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置的菜单项的actionLayout和设置背景颜色和图像,但它不尊重。在我的活动,我有:

i am setting an actionLayout on a menu item and setting background color and image, but it's not respected. in my activity, i have:

getMenuInflater().inflate(R.menu.submit_action, menu);

我submit_action是:

my submit_action is:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item android:id="@+id/action_submit"
        android:actionLayout="@layout/check"
        app:showAsAction="always"  />
</menu>

我的支票布局

my check layout is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="?android:attr/actionButtonStyle"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#e8e8e8"
    android:clickable="true"
    android:contentDescription="lol" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@null"
        android:scaleType="centerInside"
        android:src="@drawable/ic_action_tick" />

</RelativeLayout>

但即使所有这些设置的,这是怎样的操作栏出现时,没有显示我的菜单项,在所有(但它的存在,因为它回应了一下,但没有出现):

but even with all of this setup, this is how the action bar appears, not showing my menuitem at all (but it's there, because it responds to the click, but doesn't appear):

推荐答案

尝试应用程序:actionLayout =@布局/检查而不是安卓:actionLayout =@布局/检查

如果您使用的是 ActionbarSherlock AppCompat 机器人:命名空间不会为<$​​ C $ C>菜单项的工作。这是因为这些库使用,模仿了Android的API,因为他们没有在早期版本的框架存在的自定义属性。

If you're using ActionbarSherlock or AppCompat, the android: namespace will not work for MenuItems. This is because these libraries use custom attributes that mimic the Android APIs since they did not exist in earlier versions of the framework.

这篇关于actionlayout的菜单项什么都不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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