android - Toolbar Won't Show Menu Button -
i tried different methods of making menu button on android studio update couldn't make menu button appear.
@override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu_mainmenu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.settings) { return true; } return super.onoptionsitemselected(item); }
i have added code in activity , made menu.xml file containing:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/expanded_menu" android:showasaction="always" android:icon="@drawable/ic_action_menu" app:showasaction="always" android:title="button"> </item> <item android:id="@+id/credits" android:title="credits" android:orderincategory="100" /> <item android:title="settings" android:id="@+id/settings" android:orderincategory="101" /> </menu>
anyway, how can make 3 squares automatically added in older versions of android appear?
this screenshot of application, in previous versions of android studio there 3 dots @ top right corner. not there , question how add menu button.
edit: while writing app:showasaction="always"
android studio marked of line red untill wrote "=" sign, maybe error related something? maybe missed step while making items/toolbar, not know if missed anything.
i believe talking overflow button (labeled '3'):
this button appears when there not enough room display of items in options menu, or when designate specific items not shown action. handled app:showasaction
attribute. there 5 different values can apply, described follows:
ifroom : place item in app bar if there room it. if there not room items marked
"ifroom"
, items lowestorderincategory
values displayed actions, , remaining items displayed in overflow menu.withtext : include title text (defined
android:title
) action item. can include value along 1 of others flag set, separating them pipe|
.never : never place item in app bar. instead, list item in app bar's overflow menu.
always : place item in app bar. avoid using unless it's critical item appear in action bar. setting multiple items appear action items can result in them overlapping other ui in app bar.
collapseactionview : action view associated action item (as declared
android:actionlayout
orandroid:actionviewclass
) collapsible. introduced in api level 14.
therefore, if want only show overflow button, should set app:showasaction="never"
of menu items.
though, typical structure options menu show first item, , designate rest shown "ifroom"
.
Comments
Post a Comment