I recently converted my application from using Activites and TabHost to 
using Fragments and ViewPager using the Android Compat Library for API v4
I was able to fix/resolve most problems but am unable to retain the previous 
behavior with filtering text in ListViews using the 
setTextFilterEnabled<http://developer.android.com/reference/android/widget/AbsListView.html#setTextFilterEnabled(boolean)>
 method.

My ViewPagerAdapter contains Fragments which each have a ListView. As users 
swipe through the ViewPager, I would like the currently active Fragment's 
ListView to filter text as users type, just like I was able to do with the 
TabHost-Activity model. Currently, it looks like the first Fragment's 
ListView will respond correctly, but if I swipe to the next Fragment and try 
to filter its ListView, the filtering will still apply to the first one. If 
I swipe past the first two and then filter, the results are non 
deterministic. The currently active Fragment will never apply the filter. 
Sometimes a neighboring fragment will, sometimes it won't.

I tried to fix this by adding custom callbacks which let me monitor which 
Fragment is currently visible, and which are hidden. When a fragment becomes 
visible as the main Fragment of the ViewPager, I set the 
setTextFilterEnabled on its ListView to 'true', and set all others to 
'false'. This didn't seem to help at all (I verified that I was toggling the 
flag correctly for the right Fragments). 

I suspect this needs some kind of deeper integration with ViewPager, but I 
can't really figure out what I need to wire up. Any ideas on how I can make 
this work? I'm happy to much with the ACL code if needed.

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

Reply via email to