Kuldeep Kuldeep - 1 year ago 139
Android Question

Popup menu with icon on Android

My menu xml code menu.xml:

<?xml version="1.0" encoding="utf-8"?><menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Single menu item
Set id, icon and Title for each menu item
-->

<item android:id="@+id/back"
android:icon="@drawable/back1"
android:showAsAction="never"
android:title="Back" />

<item android:id="@+id/My_Profile"
android:icon="@drawable/myprofile"
android:showAsAction="never"
android:title="My Profile" />

<item android:id="@+id/Job_Alert"
android:icon="@drawable/jobalert4"
android:showAsAction="never"
android:title="Job Alert !" />

<item android:id="@+id/saved_job"
android:icon="@drawable/jobapplied"
android:title="Saved Jobs"
/>


<item android:id="@+id/Logout"
android:icon="@drawable/logout"
android:title="Logout" />
</menu>


I am calling menu xml like this

PopupMenu popup = new PopupMenu(getBaseContext(), v);
popup.getMenuInflater().inflate(R.menu.menu, popup.getMenu());
popup.show();


But it does not show the icon.

How can I set the icon on the popup menu?

Answer Source

Actually Context Menu does not support the icons.

If you want context menu/pop up menu with icons Here is the way.

You can go for QuickAction3D which servers the functionality which you want.

Check out thread which might help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download