Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewPager的嵌套onLazyInitView不执行 #783

Closed
yihuajia opened this issue Feb 26, 2018 · 6 comments
Closed

viewPager的嵌套onLazyInitView不执行 #783

yihuajia opened this issue Feb 26, 2018 · 6 comments

Comments

@yihuajia
Copy link

库的版本是1.2.7
是一个平板项目,某个模块最外层A是一个tab+viewPager,然后左侧B也是tab+viewPager,在正常左右滑动A的时候B中的onLazyInitView是可以执行到的,但是如果是点击tab的话,不会执行onLazyInitView方法

@YoKeyword
Copy link
Owner

YoKeyword commented Feb 26, 2018

ViewPager的适配器是否使用的是FragmentStatePagerAdapter ?

@yihuajia
Copy link
Author

@YoKeyword 是的

@YoKeyword
Copy link
Owner

FragmentStatePagerAdaptermUserVisibleHint在切换时有个BUG (FragmentPagerAdapter是正常的) 获取的值会被重置掉,导致Fragment的getUserVisibleHint()不准确, 之前想到了处理方法,还没放到新版本中, 下一版本会修复

在这之前,建议不要使用onLazyInitView(),自己配合setUserVisibleHint()等方法实现懒加载回调,或者可以的话使用FragmentPagerAdapter

@yihuajia
Copy link
Author

yihuajia commented Feb 27, 2018

好的,修改了缓存大小,先将就着用了。谢谢了

@YoKeyword
Copy link
Owner

YoKeyword commented Mar 8, 2018

v1.3.1,此外如果使用FragmentStatePagerAdapter,强烈建议使用v4-27.1.0+, 27.1.0修复了上面我提到的BUG

https://stackoverflow.com/questions/44052437/uservisiblehint-is-false-on-selected-viewpager-fragment-managed-by-fragmentstate

@yihuajia
Copy link
Author

好的,谢谢了,回头有空我试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants