Add separators between groups of actions bar menu items

I am creating an android action bar menu for an application. I'm looking for a way to show logical groupings of menu items. So, I have a:

enter image description here

Whereas I would like:

enter image description here

I am creating a menu like this:

@Override
public boolean onCreateOptionsMenu(Menu menu){
    //Note, on 2.3.x - 3.0 this is called when user opens the menu for the first timed
    //on 3.0+ it is called when the activity starts

    MenuInflater inflater = getMenuInflater();
    //adds the (currently empty) menu, after login it will be filled with options
    inflater.inflate(R.menu.menu, menu);

    return super.onCreateOptionsMenu(menu);
}


@Override
public boolean onPrepareOptionsMenu(Menu menu){
    menu.add("example");
    menu.add("example");
    return true;
}

      

XML Menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:compat="http://schemas.android.com/apk/res-auto"

    >
</menu>

      

I was hoping that menu groups would help, but I understand that they are only for changing all properties of menu items. At the same time, the submenu actually creates a hidden menu that opens freely when clicked.

Is there a way to create this logical grouping of menu items I'm looking for?

+3
java android android-actionbar menu


source to share


No one has answered this question yet

See similar questions:

nineteen
Custom Spinners / Dropdown Menu

or similar:

5641
What is the difference between "px", "dip", "dp" and "sp"?
3545
Differences between HashMap and Hashtable?
2956
What is the difference between public, secure, batch and private in Java?
1873
What's the difference between @Component, @Repository and @Service annotations in Spring?
1498
Difference between StringBuilder and StringBuffer
1177
What is the difference between match_parent and fill_parent?
239
How do I hide a menu item on the action bar?
2
different behavior with onCreateOptionsMenu method
1
displaying the control panel instead of the update menu item in the action bar
0
ActionBar optionsMenu not updating after call to supportInvalidateOptionsMenu



All Articles
Loading...
X
Show
Funny
Dev
Pics