java - Menu does not show up in Android studio -
this androidmanifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="k.coursera.mylocation"> <uses-permission android:name="android.permission.internet" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".mainactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".test"></activity> </application> </manifest>
when tried change theme to:
android:theme="@style/themeoverlay.appcompat.actionbar"
the menu show other function of act wouldn't work (such start new activity).
and here piece of code menu xml file:
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/deletecountry" android:title="delete" /> </menu>
and java code:
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.main, menu); return super.oncreateoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.deletecountry: madapter.removeall(); return true; default: return super.onoptionsitemselected(item); } }
Comments
Post a Comment