I have been trying to figure out why my boolean is not changing when I press the button, when I changed it manually it worked, but it doesn\'t do any thing. I have tried to
In res folder create one folder menu like drawable
Create new xml file optionmenu.xml in that folder.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menuitem"
android:title="Prefs">
</item>
<item android:id="@+id/menuitem1"
android:title="Prefs1">
</item>
</menu>
In onCreate method write this code....
setOptionMenu(R.menu.optionmenu);
and in overide method of Menu write this code.....
@Override
public boolean onOptionsItemSelected(MenuItem menu) {
switch (menu.getItemId()) {
case R.id.menuitem:
startActivity(new Intent(this, Prefs.class));
break;
case R.id.menuitem1:
startActivity(new Intent(this, Prefs1.class));
break;
default:
break;
}
return true;
}