如何在一行中设置4个android菜单图标

时间:2012-08-10 11:22:27

标签: android

我想在一行中设置4个菜单图标。在一行中显示2个mene图标,在第二行显示2个图标


这是我的菜单项代码

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Single menu item Set id, icon and Title for each menu item
-->


<item android:id="@+id/menu_bookmark"
android:icon="@drawable/homf"
android:title="Home" />

<item android:id="@+id/menu_save"
android:icon="@drawable/shopcrt"
android:title=" Shopping Cart" />

<item android:id="@+id/menu_search"
android:icon="@drawable/icon_search"
android:title="Search" />


<item android:id="@+id/about"
android:icon="@drawable/icon_share"
android:title="About" />


</menu>

1 个答案:

答案 0 :(得分:1)

您可以覆盖菜单按钮以显示带按钮的自定义视图,您可以从Menu My way project获得灵感。源代码也附上了。

enter image description here

/**
     * Manage  Menu Items Click.
     */
    @Override
    public void MenuItemSelectedEvent(CustomMenuItem selection) {

        switch (selection.getId()){




        case MENU_ITEM_FIRST:
            Intent myIntent = new Intent(CurrentActivity.this, ActivityToLaunch.class);
                    startActivity(myIntent);
            break;




        case MENU_ITEM_SECOND:
            //.....
            break;




        case MENU_ITEM_THIRD:
                    //....
            break;
        }




    }
}