Android Menu Options | Action Bar Menu Options

The menu options in Android which appear as 3 vertical dots on the action bar or any custom bar is a very utility way of providing users with selection choices without being intrusive. Here is a video on all you wanted to know about managing Menu options in Android.



The source code is as follows.

Inside the /res/menu folder, create a file start_menu.xml




<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
        android:id="@+id/action_login"
        android:orderInCategory="1"
        android:showAsAction="never"
        android:title="@string/login"/>
<item
        android:id="@+id/action_orderhistory"
        android:orderInCategory="2"
        android:showAsAction="never"
        android:title="@string/orderhistory"/>

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="3"
        android:showAsAction="never"
        android:title="@string/action_settings"/>
    
</menu>

In your activity you can put this code to inflate the menu



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

No comments:

Post a Comment