Search code examples
androidactionbarsherlock

android - Action bar sherlock add unnecessary button


i use action bar sherlock and i set custom layout in the menu:

<item
    android:id="@+id/action_menu"
    android:actionLayout="@layout/menu_item"
    android:icon="@drawable/b_menu"
    android:orderInCategory="1"
    android:showAsAction="always"/>
<item
    android:id="@+id/action_audio"
    android:actionLayout="@layout/audio_item"
    android:icon="@drawable/b_audio"
    android:orderInCategory="2"
    android:showAsAction="always"/>
<item
    android:id="@+id/action_mySong_details"
    android:actionLayout="@layout/my_song_properties"
    android:icon="@drawable/b_mysong"
    android:orderInCategory="2"
    android:showAsAction="always"/>

to control those items i use:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    /** Create an option menu from res/menu/items.xml */
    getSherlock().getMenuInflater().inflate(R.menu.main_tab, menu);

    /** Get the action view of the menu item whose id is search */
    View v = (View) menu.findItem(R.id.action_menu).getActionView();
    Button b = (Button) v.findViewById(R.id.btnMenu);
    return super.onCreateOptionsMenu(menu);
}

for some reason the action bar add unnecessary item, does anybody knows how this case happene?


Solution

  • I found the mistake: i remove the android:orderInCategory from all the items and it's ok now, i this case i don't need this option.