Hi,

menu.add() returns the menu item that was created. You can create a
global variable, assign the returned menu to this global variable, and
then access this any time you like.

E.g.:

In your global variable definitions, add:
MenuItem startMenu;

in onCreateOptionsMenu() you add:

startMenu=menu.add(0, 1, 0, "Start");

In you onOptionsItemSelected, you then just have to state:

startMenu.setTitle("Pause");

Cheers,

Tobias

On Jan 4, 1:19 pm, "Sasikumar.S" <sasikumar.it1...@gmail.com> wrote:
> Hi,
>
> I added 2 menus.
>
>         menu.add(0, 1, 0, "Start");
>         menu.add(0, 2, 0, "Stop");
>
> public boolean onOptionsItemSelected(MenuItem item)
>     {
>         switch (item.getItemId()) {
>         case 1:
>             if(item.getTitle().equals("Start"))
>             {
>                 item.setTitle("Pause");
>             }
>             return true;
>         case 2:
>
>             return true;
>         }
>         return false;
>     }
>
> when i click the stop menu, the start menu name should be changed.
>
> How to change that?...
>
> --
> Thanks & Regards
> Sasikumar.S

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to