英文:
Option menu icon is not showing
问题
这是我在menu.xml中的内容:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/aq"
android:icon="@drawable/ic_baseline_comment_24"
android:title="提问" />
<item
android:id="@+id/ri"
android:icon="@drawable/ic_baseline_report_problem_24"
android:title="报告问题" />
<item
android:id="@+id/feed"
android:icon="@drawable/ic_baseline_feedback_24"
android:title="反馈" />
<item
android:title="更多">
<menu>
<item
android:icon="@drawable/ic_baseline_comment_24"
android:title="检查" />
</menu>
</item>
</menu>
感谢您提前的帮助!
英文:
I'm trying to make an options menu with icons. I'm following this but it's not working. And when I went through previously asked similar questions, they all are pointing towards setting showAsAction always or ifRoom. But I want to make it work while it's set as disabled.
app:showAsAction="never"
This is what I've in my menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/aq"
android:icon="@drawable/ic_baseline_comment_24"
android:title="Ask Query"/>
<item
android:id="@+id/ri"
android:icon="@drawable/ic_baseline_report_problem_24"
android:title="Report Issue"/>
<item
android:id="@+id/feed"
android:icon="@drawable/ic_baseline_feedback_24"
android:title="Feedback"/>
</menu>
But what I want to do is working with sub menu in the same activity:
<item
android:title="More">
<menu>
<item
android:icon="@drawable/ic_baseline_comment_24"
android:title="Check"/>
</menu>
</item>
Thank you in advance for your help!
答案1
得分: 1
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:icon="@drawable/ic_baseline_more_vert_24"
android:title="more"
app:showAsAction="always">
<menu>
<item
android:id="@+id/aq"
android:icon="@drawable/ic_baseline_comment_24"
android:title="Ask Query"/>
<item
android:id="@+id/ri"
android:icon="@drawable/ic_baseline_report_problem_24"
android:title="Report Issue"/>
<item
android:id="@+id/feed"
android:icon="@drawable/ic_baseline_feedback_24"
android:title="Feedback"/>
</menu>
</item>
</menu>
This article helped me with it.
<details>
<summary>英文:</summary>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:icon="@drawable/ic_baseline_more_vert_24"
android:title="more"
app:showAsAction="always">
<menu>
<item
android:id="@+id/aq"
android:icon="@drawable/ic_baseline_comment_24"
android:title="Ask Query"/>
<item
android:id="@+id/ri"
android:icon="@drawable/ic_baseline_report_problem_24"
android:title="Report Issue"/>
<item
android:id="@+id/feed"
android:icon="@drawable/ic_baseline_feedback_24"
android:title="Feedback"/>
</menu>
</item>
</menu>
Doing it this way helped me achieve what I want. [This][1] article helped me with it.
[1]: https://www.codingdemos.com/android-options-menu-icon/
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论