java - How to add icon to the menu of actionbar in android studio -
my app has menu (the default icon of menu 3 dots) contains several items. want add icon menu not icon actionbar. research 3 hours of tutorials adding icons actionbar not menu. knows how or have tutorial link?
on top right
check code ,
in .java file add oncreateoptionsmenu
code,
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.menu_inbox, menu); //.xml file name return super.oncreateoptionsmenu(menu); }
now, create menu_inbox.xml defined above in java code
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_websearch" android:icon="@mipmap/ic_launcher_menu_o" //icon 3 dots android:orderincategory="3" //number of item in android:title="info" //title on longpress on menu icon app:showasaction="ifroom"> //to show menu on upper side <menu> <item android:id="@+id/action_reply" android:title="@string/reply" /> <item android:id="@+id/action_replyall" android:title="@string/replyall" /> <item android:id="@+id/action_forward" android:title="@string/forward" /> </menu> </item> </menu>
Comments
Post a Comment