Drop Down Menu on Action bar

I am working on an android application Menu with Action Bar, I want to put the dropdown menu in the action bar like the one present in Google Maps application.
Google Maps ActionBar

Can somebody help me? How to achieve this Please point to some easy tutorial that I can follow.

  • Android: Camera preview orientation in portrait mode
  • A developer tool for designing an SQLite database for Android
  • Understanding fragments backstack
  • How to style the menu items on an Android action bar
  • How do I know that the scrollview is already scrolled to the bottom?
  • How to switch android version in local repo?
  • Related posts:

    In Android development, what files should be committed to a repository?
    LinearLayout, RelativeLayout, etc. margins do not work as expected
    Drawing over a view and all it's children
    Android GCM delivery monitoring
    How do I determine whether a path is a local file or not
    Android: DialogPreference color/style?
  • Activity not started, its current task has been brought to the front
  • Set Login/Logout Text for Button in Facebook Android SDK 4.0?
  • Add the loading screen in starting of the android application
  • File Upload in WebView
  • Android - Copy assets to internal storage
  • macbook adb cannot open interface
  • 2 Solutions collect form web for “Drop Down Menu on Action bar”

    Add this to your activity onCreate() method:

    // Adapter
    SpinnerAdapter adapter =
            ArrayAdapter.createFromResource(this, R.array.actions,
    // Callback
    OnNavigationListener callback = new OnNavigationListener() {
        String[] items = getResources().getStringArray(R.array.actions); // List items from res
        public boolean onNavigationItemSelected(int position, long id) {
            // Do stuff when navigation item is selected
            Log.d("NavigationItemSelected", items[position]); // Debug
            return true;
    // Action Bar
    ActionBar actions = getActionBar();
    actions.setListNavigationCallbacks(adapter, callback);

    This example requires an array resource for the list items:


    <string-array name="actions">
        <item>Item 1</item>
        <item>Item 2</item>
        <item>Item 3</item>

    Alternatively you could create your own adapter and layout extended from SpinnerAdapter to display more advanced or dynamic list items.

    To make the activity onCreate code even neater you could also change your Activity to implement OnNavigationListener and add the override onNavigationItemSelected with the callback code. Then change “callback” to “this” in the setListNavigationCallbacks() method.

    Please note you will need to target API 11+ for the action bar, otherwise you will need to add version checking or a support library.

    check this Link also it is helpful example Example link

    GoogleMap map;
    TextView txt;
    String[] mapTypes={"Normal","Hybrid","Satellite","Terrain"};
    protected void onCreate(Bundle savedInstanceState) {
        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
    //to set map Type
    //To set the marker on map on specific location using lat lag
        // latitude and longitude
        double latitude = 18.520430300000000000;
        double longitude = 73.856743699999920000;
        // create marker
        MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("My Location");
        // change color to the marker icon
        // adding marker
        // Create an array adapter to populate dropdownlist 
        ArrayAdapter<String> adapter =new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, mapTypes);
        /** Enabling dropdown list navigation for the action bar */
        /** Defining Navigation listener */
        ActionBar.OnNavigationListener navigationListener=new ActionBar.OnNavigationListener() {
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {
                Toast.makeText(getBaseContext(), "U Select : "+mapTypes[itemPosition], Toast.LENGTH_SHORT).show();
                if (mapTypes[itemPosition].equals("Normal")) {
                else if (mapTypes[itemPosition].equals("Hybrid")) {
                else if (mapTypes[itemPosition].equals("Satellite")) {
                else if (mapTypes[itemPosition].equals("Terrain")) {
                return false;
        // Setting dropdown items and item navigation listener for the actionbar 
        getActionBar().setListNavigationCallbacks(adapter, navigationListener);
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.