You will need to have the activity populate the options menu and call to the
current fragment when an item is selected.

On Tue, Jul 26, 2011 at 3:39 PM, Sam <sam.oak...@blork.co.uk> wrote:

> I have a FragmentActivity which hosts a FragmentStatePagerAdapter. The
> pager contains multiple instances of the same fragment, in order that
> the user can swipe between the items in a list. I want to be able to
> provide the user with an options menu which will act only on the
> visible item.
>
> For example, I have a list of images displayed in imageviews inside
> fragments. I want an option menu item allowing the user to set the
> image as their wallpaper.
>
> At the moment when I try this, when onPrepareOptionsMenu is called,
> the code is called in multiple fragments (usually the current + next
> one). The same when an item is selected. This causes the wrong image
> to be set as the wallpaper.
>
> How can I prevent the options menu triggering for more than the
> currently visible fragment?
>
> Question also posted to StackOverflow:
>
> http://stackoverflow.com/questions/6831544/using-options-menu-in-a-multi-fragment-activity
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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