Reputation: 1073
The menu item called "action_settings" is displayed on my Nexus 5 but not with the gear icon I specified in XML, with an android option icon that I didn't specify. It is not displayed at all on a Galaxy S2. Anyone know why this strange behaviour is happening? The rest of my menus show as expected. Thanks.
EDIT It's probably because it doesn't fit, because when I click the phones menu button it goes straight to the 2 checkboxes I have in the action_settings menu item. But half the action bar is still free to be used :/
Edit the icon showing on my Nexus 5 is called an "overflow" icon. 3 vertical squares. Perhaps suggesting too many actionbar icons.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.dressing_room, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
switch (itemId) {
case R.id.menu_femaleHat : addClothes(R.id.menu_femaleHat);
break;
case R.id.menu_femalePants: addClothes(R.id.menu_femalePants);
break;
case R.id.menu_femaleTop: addClothes(R.id.menu_femaleTop);
break;
case R.id.menu_maleHat: addClothes(R.id.menu_maleHat);
break;
case R.id.menu_malePants: addClothes(R.id.menu_malePants);
break;
case R.id.menu_maleTop: addClothes(R.id.menu_maleTop);
break;
case R.id.menuMaleHair: addClothes(R.id.menuMaleHair);
break;
case R.id.menuFemaleHair: addClothes(R.id.menuFemaleHair);
break;
case R.id.menuMaleAccessories: addClothes(R.id.menuMaleAccessories);
break;
case R.id.menuFemaleAccessories: addClothes(R.id.menuFemaleAccessories);
break;
case R.id.action_save: saveClicked();// cropImage();
break;
case R.id.action_cancel: goToStartScreen();// cropImage();
break;
case R.id.uniformScale:
changeAnisotropic(item);
break;
case R.id.rotation:
changeRotate(item);
break;
default: Log.d("wrong menu","Invalid option");
break;
}
return super.onOptionsItemSelected(item);
}
<item
android:id="@+id/menu_sticker"
android:showAsAction="always"
android:icon="@drawable/ic_action_add"
android:title="Add Sticker">
<menu>
<item
android:id="@+id/menu_male"
android:showAsAction="always"
android:title="Male">
<menu>
<item
android:id="@+id/menu_add_clothes"
android:title="Add Clothes">
<menu>
<item
android:id="@+id/menu_maleHat"
android:title="Hat"/>
<item
android:id="@+id/menu_maleTop"
android:title="Top"/>
<item
android:id="@+id/menu_malePants"
android:title="Pants"/>
</menu>
</item>
<item
android:id="@+id/menuMaleAccessories"
android:showAsAction="always"
android:title="Add Accessories">
</item>
<item
android:id="@+id/menuMaleHair"
android:showAsAction="always"
android:title="Add Hair">
</item>
</menu>
</item>
<item
android:id="@+id/menu_female"
android:showAsAction="always"
android:title="Female">
<menu>
<item
android:id="@+id/menu_add_clothes"
android:title="Add Clothes">
<menu>
<item
android:id="@+id/menu_femaleHat"
android:title="Hat"/>
<item
android:id="@+id/menu_femaleTop"
android:title="Top"/>
<item
android:id="@+id/menu_femalePants"
android:title="Pants"/>
</menu>
</item>
<item
android:id="@+id/menuFemaleAccessories"
android:showAsAction="always"
android:title="Add Accessories">
</item>
<item
android:id="@+id/menuFemaleHair"
android:showAsAction="always"
android:title="Add Hair">
</item>
</menu>
</item>
</menu>
</item>
<item
android:id="@+id/action_settings"
android:showAsAction="always"
android:title="Sticker Settings"
android:icon="@drawable/ic_action_gear">
<group android:checkableBehavior="all">
<item android:id="@+id/uniformScale"
android:title="Enable Re-sizing"
android:checked="true" />
<item android:id="@+id/rotation"
android:title="Enable Rotation"
android:checked="false" />
</group>
</item>
<item
android:id="@+id/action_save"
android:showAsAction="always"
android:title="@string/action_save"
android:icon="@drawable/ic_action_save">
</item>
<item
android:id="@+id/action_cancel"
android:showAsAction="always"
android:title="Cancel"
android:icon="@drawable/ic_action_cancel">
</item>
Upvotes: 0
Views: 1110
Reputation: 10083
Did you check this
I have 3 menu icons on the menu bar
For the purposes of this answer, I am assuming that by "menu bar" you are referring to the action bar.
but everytime it only shows 2 icons, the last one is in nowhere
The last one is available by pressing the MENU button, for devices (or emulators) that have an off-screen MENU button.
there is enough space for 3 icons, why only 2 are shown?
Presumably because Android disagrees with your assessment of whether or not there is enough space for 3 icons.
if the system thinks the space is not enough for the 3rd icon, why doesn't
it combine the 2nd and 3rd icon into an overflow menu?
I have no idea why you think forcing the 2nd icon -- which, by your admission, fits -- into the overflow menu would be a good idea. The 3rd menu item is in the overflow menu, which is accessed via the MENU button on devices that have one or a three-vertical-dots button on the action bar for devices that lack a MENU button
Upvotes: 2