I'm facing with strange problem, my old Android project suddenly is not showing menu options.
Code for menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_preferences"
android:icon="@drawable/icon_preferences"
android:showAsAction="always"
android:visible="true"
android:title="Preferences" />
<item android:id="@+id/menu_datatransfer"
android:icon="@drawable/transfer"
android:showAsAction="always"
android:visible="true"
android:title="Data transfer" />
</menu>
And this is for creating menu:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.layout.menu, menu);
return true;
}
The strange things is that if I put breakpoint on those lines debuger doesn't stop on them. Seems that somehow onCreateOptionsMenu is not called while application is starting. How is this possible?
SDK version is 17.
You must add
onOptionsItemSelectedlike below: