Reputation: 215
I am trying to use option menus for my application . When I add 2 MenuItem it shown in a single row, but i need only one item in a row and other in next row. Please help me.
Thanks..
Upvotes: 4
Views: 2795
Reputation: 23432
You cannot. The Android system handles how the options menu is laid out and there are no options to achieve what you want. You would have to make your own View, and then slide this up/down when the menu button is pressed.
Upvotes: 3
Reputation: 2250
tr this code
<item android:id="@+id/last_most_item"
android:orderInCategory="10"
android:title="@string/last_most_often" />
<item android:id="@+id/middle_most_item"
android:orderInCategory="7"
android:title="@string/middle_most_often" />
<item android:id="@+id/first_most_item"
android:orderInCategory="4"
android:title="@string/first_most_often" />
</group>
Upvotes: 1
Reputation: 13045
I'm not sure it's possible but try with the MenuInflater
and a menu resource file.
In your menu resource file, try to embed each item in a separated <menu>
element, something like this :
<menu>
<item>
<menu>
<item android:id="@+id/item1"
android:title="@string/item1" />
</menu>
</item>
<item>
<menu>
<item android:id="@+id/item2"
android:title="@string/item2" />
</menu>
</item>
</menu>
Maybe it will force the inflater to show the items in 2 separated lines, sorry I don't have the time to test it. If it's not working, replace the submenus with <group>
elements and retest.
Upvotes: 1