Search code examples
androidandroid-actionbaractionbarsherlock

Android App Shows Both Setting Bar and ActionBar Overflow for Non-Hardware Device


This is my first time working with the Action Bar in Android. I'm seeing an issue where both overflow menu displays in the ActionBar and the bottom of the screen.

From my understanding the bottom settings bar should only display if the app uses the legacy settings operations. I thought I've followed everything needed to set the action bar and overflow up properly to work with the new android APIs. For a frame of reference, I'm debugging on the HTC One.

At first I thought it might be related to the fact I'm using ActionBarSherlock, but I removed the references to the library and used the standard Android library classes -- that didn't help.

I sense that I'm missing something minor. Any help would be appreciated.

double overflow http://goo.gl/1AB6S

My activity has the following code:

public class MainActivity extends SherlockActivity
    {
        static final LatLng POINT = new LatLng(44.52515, -89.571533);

        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                    .getMap();

            map.moveCamera(CameraUpdateFactory.newLatLngZoom(POINT, 15));

            // Zoom in, animating the camera.
            map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
        }

            @Override
        public boolean onCreateOptionsMenu(Menu menu)
        {
            getSupportMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }

            @Override
        public boolean onOptionsItemSelected(MenuItem item) {

            switch(item.getItemId()) 
            {
                case R.id.action_routes :
                    // do something here
                    break;
                case R.id.action_settings:
                    // do something here
                    break;
            }

            return true;
        }
    }

and my activity_main.xml for the menu:

<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/action_routes"
        android:orderInCategory="100"
        android:showAsAction="always"
        android:icon="@drawable/ic_route"
        android:title="@string/action_routes" />        
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>
</menu>

Solution

  • You need to set your android:targetSdkVersion to 14 or higher to avoid this effect.