如何添加一个按钮,菜单项?菜单项、按钮

2023-09-12 03:32:06 作者:朕要你何用

这可能是很容易的。我似乎就是无法把它做。如何添加一个按钮,菜单项?到目前为止,我只能够添加文本。以下是我有:

 < XML版本=1.0编码=UTF-8&GT?;
<菜单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>
    <项目
        机器人:ID =@ + ID / btn_id
        机器人:orderInCategory =100
        机器人:showAsAction =总是
        机器人:可见=真
        机器人:标题=@字符串/ need_button/>
     ...
< /菜单>
 

解决方案

尝试添加安卓图标<项目> ,因为现在,没有图标显示。

在Excel中添加菜单和菜单项按钮

This is probably very easy. I just can't seem to get it done. How do I add a button as a menu item? So far I am only able to add texts. Here is what I have:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item
        android:id="@+id/btn_id"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:visible="true"
        android:title="@string/need_button"/>
     ...
</menu>

解决方案

Try adding android:icon to your <item>, as right now, there is no icon to be displayed.