I am trying to manage the options items, making one button visible and
another invisible based on whether a background service is active.
Here's a snippet of my menu/option.xml:
<item android:id="@+id/arm"
android:title="Arm"
/>
<item android:id="@+id/disarm"
android:title="Disarm"
android:visible="false"
android:enabled="false"
/>
and my onPrepareOptionsMenu():
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
ActivityManager.RunningServiceInfo amRSI = new
ActivityManager.RunningServiceInfo();
if(amRSI.started) {
menu
.findItem(R.id.arm)
.setVisible(false);
} else {
menu
.findItem(R.id.disarm)
.setVisible(true)
.setEnabled(true);
}
return true;
}
However, both buttons show when hitting the menu tab in the emulator
before starting the service.
Can someone lend me a hand?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---