On Wed, Jan 13, 2016 at 5:38 AM, Hugo Teijiz <hugo.tei...@gmail.com> wrote:

> OnSelectedTab Listener executed correctly, and execute then setCurrentItem
> of viewPager, but onCreateView of Fragment doesn't execute.


By default, ViewPager keeps one off-screen item cached as an optimization
(see
http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit%28int%29
).

In a set of 3, the middle one will never get destroyed as it's always the
one offscreen relative to the other two. When the pager is using a
FragmentPagerAdapter, as in your case, that means the Fragment is kept
alive, thus it's onCreate and onCreateView methods are not called.

If you are needing to do some kind of refresh when the tab is selected,
move that logic to onStart or onResume.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
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 android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CANCScgi6g3m3-NhboggYVv05w%2BqcDxC8s6%2BZWzSAJ4fCJyZp%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to