Hi Below is the code I am using to create option menu in my FragmentActivity :-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
// Menu options to set and cancel the alarm.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// When the user clicks START ALARM, set the alarm.
case R.id.start_action:
alarm.setAlarm(this);
return true;
// When the user clicks CANCEL ALARM, cancel the alarm.
case R.id.cancel_action:
alarm.cancelAlarm(this);
return true;
}
return false;
}
Will anybody tell me why it's not working? It is not affecting app but nothing is happening when I click the option menu button from device. Please Help to resolve this. Thanks in advance!
Below is my main.xml :-
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/start_action"
android:showAsAction="ifRoom|withText"
android:title="@string/start_text" />
<item android:id="@+id/cancel_action"
android:showAsAction="ifRoom|withText"
android:title="@string/cancel_text" />
</menu>