简体   繁体   中英

How can I add different menu items to multiple context menus?

I need to change icon for my item menu when i click. (android)

a basic example, when you create your menu

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    return true;
}

inside your res/menu folder you will change your icon inside your menu.xml file

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/noticias" 
android:orderInCategory="0" android:title="Menu Item" android:icon="@drawable/menu_icon"></item>
</menu>

menu_icon.png must be inside res/drawable folder...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM