Question

I would like to create a menu to appear on the screen when the Menu button is pressed. I've implemented it and it appears in the bottom of the page but not where I would like. My code is here with an image of what I am trying to achieve.

main.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:id="@+id/expandall"
    android:orderInCategory="100"
    android:showAsAction="always"
    android:title="Expand All"/>


<item
    android:id="@+id/collapseall"
    android:orderInCategory="100"
    android:showAsAction="withText"
    android:title="Collapse All"/>


<item
    android:id="@+id/myprofile"
    android:orderInCategory="100"
    android:showAsAction="withText"
    android:title="My Profile"/>

<item
    android:id="@+id/signout"
    android:orderInCategory="100"
    android:showAsAction="always"
    android:title="Sign Out"/>

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.collapseall:
    // Single menu item is selected do something

    collapseAll();

    return true;

case R.id.expandall:

    expandAll();

    return true;
  }
}

My desired Menu:

enter image description here

My Current Menu

enter image description here

Was it helpful?

Solution

try removing android:orderInCategory from all item

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top