Android Vertical Menu

人走茶凉 提交于 2019-12-11 03:34:21

问题


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 the one i would like... Hereunder my code and my goal picture to achieve

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:

My current Menu:

Edit:

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"/>
</menu>

来源:https://stackoverflow.com/questions/22254719/android-vertical-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!