Unfortunately this is really not straightforward. You'll have to work 
around in order to make that work. You basically have the following 
possibilities:

1. You can get the currently visible page index number from the pager. Use 
that number to get the correct fragment from your adapter. Then you can 
retrieve the currently visible fragment from your fragment pager adapter. 
But be careful: your adapter needs to internally cache the created 
fragments, otherwise you can always get a new instance of your fragment.

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.

On Monday, January 28, 2013 7:50:26 PM UTC-6, dashman wrote:
>
> If someone can help me with this - i'd appreciate it. At wits end here.
>
> Again a FragmentActivity sub-class with the layout being
> a ViewPager and a PagerTitleStrip inside it.
>
> I'm trying to get the current active displayed Fragment.
>
>
> I think the solution has to do with fragmentManager.findFragmentById(id);
>
> but i'm creating my Fragment as a sub-class of Fragment and just
> creating a new instance and passing to the adapter.
>
> No where can i set the ID - it's final method in Fragment
>
>
>
>
>
> On Monday, January 28, 2013 5:29:05 PM UTC-5, dashman wrote:
>>
>> I've got a FragmentActivity sub-class app with a ViewPager.
>>
>> also has a .PagerTitleStrip.
>>
>> Essentially a view with about 4 Fragments that can be laterally navigated.
>>
>> How can I find the active Fragment on the screen.
>>
>>

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


Reply via email to