android - action bar not showing options menu in jelly bean -
action bar not show options menu in jelly bean,while shown in lollipop. here styles.xml`
<resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <item name="colorprimary">#00796b</item> <item name="colorprimarydark">#004d40</item> <item name="coloraccent">#c51162</item> <item name="android:textcolorprimary">@color/abc_primary_text_disable_only_material_dark</item> </style> </resources>`
here app gradle
compilesdkversion 22 buildtoolsversion "22.0.1" defaultconfig { applicationid "com.example.dell.syncytium" minsdkversion 16 targetsdkversion 22 versioncode 1 versionname "1.0" }
my mainactivity extends appcompatactivity. please me.thanks in advance
@override public boolean oncreateoptionsmenu(menu menu) { boolean result = super.oncreateoptionsmenu(menu); menu.add(0, logoutmenu, 0, "logout"); menu.add(0,play,1,"play music"); menu.add(0,stop,2,"stop music"); return result; }
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".mainactivity"> <item android:id="@+id/connect_scan" android:icon="@drawable/menu" android:showasaction="ifroom|withtext"/> <item android:id="@+id/discoverable" android:icon="@android:drawable/ic_menu_mylocation" android:showasaction="ifroom|withtext"/> </menu>
mainactivity.java
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.option_menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.menu: break; case r.id.discoverable: break; } return false; } }
Comments
Post a Comment