Reputation: 1027
hi i wanna make grid option menu instead of list option menu
but no mather i try (xml or programmatically) i always get list option menu like this
i wanna create grid menu something like this
this is code i use
XML
<item android:id="@+id/item1" android:title="Option1"></item>
<item android:id="@+id/item2" android:title="Option2"></item>
<item android:id="@+id/item3" android:title="Option3"></item>
<item android:id="@+id/item4" android:title="Option4"></item>
<item android:id="@+id/item5" android:title="Option5"></item>
<item android:id="@+id/item6" android:title="Option6"></item>
Programatically
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1, 1, 0, "Option1");
menu.add(1, 2, 1, "Option2");
menu.add(1, 3, 2, "Option3");
menu.add(1, 4, 3, "Option4");
menu.add(1, 5, 4, "Option5");
menu.add(2, 6, 0, "Option6");
menu.add(2, 7, 1, "Option7");
menu.add(2, 8, 2, "Option8");
menu.add(2, 9, 3, "Option9");
menu.add(2, 10, 4, "Option10");
return true;
}
Update @Krupa Patel
hm, i used android 2.3.3 and you're right i used holo theme
i don't mind to change theme, but i can't find
@android:style/Theme.Holo.Wallpaper.NoTitleBar
instead i found
android:theme="@style/AppTheme" > in AandroidmMnifest.xml (root firectory)
is it right? i try to change it to
android:theme="@style/Theme.Wallpaper.NoTitleBar" >
but it's give error message
Update
i try to create new project and change theme (wizardly)
i see there is available 4 option for theme when i create new project
"none" - "Holo Dark" - "Holo Light" - "Holo Light with Dark Action Bar"
i choice "none" and when i run my new project menu..it's still become list menu not as i expect....any idea?
Upvotes: 1
Views: 504
Reputation: 3359
Displaying option menu as grid-style in Android 4.0.3. is not working, because you may used @android:style/Theme.Holo for your application. Menu of Theme.Holo was set for displaying in list-style.
The solutions are:
@android:style/Theme.Wallpaper.NoTitleBar
instead of @android:style/Theme.Holo.Wallpaper.NoTitleBar
Hope this will help!
Upvotes: 1