Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding icon with submenu items

Tags:

android

I have made submenu with some items in it. Now I want to add different icon with submenu items. I have also applied the code to the menu items for adding icon but it is not showing me icons my code is this:

public boolean onCreateOptionsMEnu(Menu m) {
    SubMenu s1 = m.addSubMenu("menu1");
    s1.add(0,0,1,"1").setIcon(R.drawable.icon1);
    s1.add(0,1,2,"2").setIcon(R.drawable.icon2);

    return super.onCreateOptionsMenu(m);
}
like image 546
sachit Avatar asked Sep 28 '12 05:09

sachit


1 Answers

Submenus don't support icons.

https://developer.android.com/guide/topics/ui/menus.html:

Icon Menu
This is the collection of items initially visible at the bottom of the screen at the press of the MENU key. It supports a maximum of six menu items. THESE ARE the only menu items that support icons and the only menu items that do not support checkboxes or radio buttons.

like image 79
Marcin S. Avatar answered Oct 09 '22 00:10

Marcin S.