> 1. You can get the currently visible page index number from the pager. Use
> that number to get the correct fragment from your adapter. But be careful:
> your adapter needs to internally cache the created fragments, otherwise you
> can always get a new instance of your fragment.
>
> That's what's happening - i'm getting a new instance.
FragmentPagerAdapter adapter =
(FragmentPagerAdapter)mViewPager.getAdapter();
Fragment fr = adapter.getItem(
mViewPager.getCurrentItem() );
What do i need to do?
> 2. You can let your Fragment itself tell your Activity that it is
> currently visible. You can check that in your fragment by calling
> Fragment.getUserVisibleHint(). Use the latest version of
> Fragment(State)PagerAdapter. Previous versions did not set that hint
> correctly.
>
>
Problem is getting to the Fragment object itself - can't get it unless I
store references in my Activity.
I'm sub-classing FragmentPagerAdapter for my adapter...
and just came across getItemId() which lets you set an id as the fragments
are created by the adapter.
i would have thought that then fragmentManager.findFragmentById() would
have worked.
I've verified the getItemid() method is being called.
but still no go.
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.