This worked after restarting eclipse ... sorry for the noise.
On Sep 14, 10:13 am, Ostaski <[email protected]> wrote:
> Logic was a bit off:
> if(amRSI.started) {
> menu
> .findItem(R.id.arm)
> .setVisible(false)
> .setEnabled(false);
> menu
> .findItem(R.id.disarm)
> .setVisible(true)
> .setEnabled(true);
> } else {
> menu
> .findItem(R.id.arm)
> .setVisible(true)
> .setEnabled(true);
> menu
> .findItem(R.id.disarm)
> .setVisible(false)
> .setEnabled(false);
> }
> return true;
> }
>
> Still showing both buttons, though.
>
> On Sep 12, 5:17 pm, Ostaski <[email protected]> wrote:
>
>
>
> > 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.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---