设置菜单项的标题出现在Android上的所有帽出现在、菜单项、标题、Android

2023-09-12 22:04:41 作者:除了帅我一无所有

我有一个菜单项,在How我添加一个按钮,菜单项?。当我使用的图标,我可以点击图标罚款。但是,当我使用 actionLayout ,我收到的点击没有反应。这里是按钮 actionLayout 点:

I have a menu item as explained in How do I add a button as a menu item?. When I use an icon, I can click on the icon fine. But when I use an actionLayout, I am getting no response on click. Here is the button the actionLayout points to:

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

    <Button
        android:id="@+id/my_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:layout_marginRight="15dp"
        android:background="#999999"
        android:text="Apple" />

</RelativeLayout>

任何想法如何解决这个问题?我们的想法是使用一个可绘制的我自己的看法吧。

Any ideas how to fix this problem? The idea is to use my own view instead of a drawable.

推荐答案

其实我看着办吧。我用

<Button  xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:layout_marginRight="15dp"
    android:background="#999999"
    android:text="Apple" />

与getActionView

with getActionView

 
精彩推荐
图片推荐