我正在android studio中开发一个抽屉导航 Activity ,在菜单文件夹的左上角有一个设置项。我想删除它并在操作栏中添加一个图像按钮。谁能告诉我如何添加该图像按钮以及如何在主 Activity 中对该按钮执行单击事件。
查看下面的图片以供引用 -
最佳答案
我希望这有帮助,请将其添加到您的 menu.xml
布局中 -
The showAsAction attribute allows you to define how the action is displayed. For example, the ifRoom attribute defines that the action is only displayed in the action bar if there is sufficient screen space available.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="always"
android:icon="@drawable/ic_settings"
android:title="Settings">
</item>
</menu>
关于java - 如何用图像按钮替换设置项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46192191/