[android-developers] Re: Technique for displaying different options menus
Hi, nice solution, I'll try do adapt it for my case. Thanks! On Feb 8, 3:32 pm, Al wrote: > Hi, I am doing this using the following method: > > - Declare int constants which will be unique to each button > - After initializing button variables via findViewById, use > View#setTag to set the unique ID to that button, and the > onClickListener to 'this' > - Declare another int variable which will hold the current state > (mState in the example below) > > - Implement the OnClickListener method in the following way: > Integer id = (Integer) view.getTag(); > mState = id; > switch (id) { > > case BUTTON_1: > //do stuff > break; > > case BUTTON_2: > //do more stuff > break; > > } > > - Create the menu as normal in onCreateMenuOptions > - In onPrepareMenuOptions (which is called each time the menu will be > shown), do something like this: > > switch (mState) { > > case BUTTON_1: > //hide/show certain menu groups/items > break; > > //etc, etc > > } > > Hope this helps. > > On Feb 8, 12:19 pm, "mobilek...@googlemail.com" > > wrote: > > Hi, > > I'm trying to figure out a way to display different option menu groups > > at a time based on various events. > > For instanece, if the click listeners on certain views have been > > triggered, the activity should bring up a specific option menu. On the > > other hand if they are not on focussed, by pressing the menu button > > the activity should display different more generic menu options. I've > > played around with Menu.setGroupVisible(int groud, boolean visible), > > however, I couldn't work out a way to have it working properly. I've > > been stuck on this for a day now. Any suggestions are welcomed! Many > > Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Technique for displaying different options menus
Hi, I am doing this using the following method: - Declare int constants which will be unique to each button - After initializing button variables via findViewById, use View#setTag to set the unique ID to that button, and the onClickListener to 'this' - Declare another int variable which will hold the current state (mState in the example below) - Implement the OnClickListener method in the following way: Integer id = (Integer) view.getTag(); mState = id; switch (id) { case BUTTON_1: //do stuff break; case BUTTON_2: //do more stuff break; } - Create the menu as normal in onCreateMenuOptions - In onPrepareMenuOptions (which is called each time the menu will be shown), do something like this: switch (mState) { case BUTTON_1: //hide/show certain menu groups/items break; //etc, etc } Hope this helps. On Feb 8, 12:19 pm, "mobilek...@googlemail.com" wrote: > Hi, > I'm trying to figure out a way to display different option menu groups > at a time based on various events. > For instanece, if the click listeners on certain views have been > triggered, the activity should bring up a specific option menu. On the > other hand if they are not on focussed, by pressing the menu button > the activity should display different more generic menu options. I've > played around with Menu.setGroupVisible(int groud, boolean visible), > however, I couldn't work out a way to have it working properly. I've > been stuck on this for a day now. Any suggestions are welcomed! Many > Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: Technique for displaying different options menus
Hi, I am doing this using the following method: - Declare int constants which will be unique to each button - After initializing button variables via findViewById, use View#setTag to set the unique ID to that button, and the onClickListener to 'this' - Declare another int variable which will hold the current state (mState in the example below) - Implement the OnClickListener method in the following way: Integer id = (Integer) view.getTag(); mState = id; switch (id) { case BUTTON_1: //do stuff break; case BUTTON_2: //do more stuff break; } - Create the menu as normal in onCreateMenuOptions - In onPrepareMenuOptions (which is called each time the menu will be shown), do something like this: switch (mState) { case BUTTON_1: //hide/show certain menu groups/items break; //etc, etc } Hope this helps. On Feb 8, 12:19 pm, "mobilek...@googlemail.com" wrote: > Hi, > I'm trying to figure out a way to display different option menu groups > at a time based on various events. > For instanece, if the click listeners on certain views have been > triggered, the activity should bring up a specific option menu. On the > other hand if they are not on focussed, by pressing the menu button > the activity should display different more generic menu options. I've > played around with Menu.setGroupVisible(int groud, boolean visible), > however, I couldn't work out a way to have it working properly. I've > been stuck on this for a day now. Any suggestions are welcomed! Many > Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---