上面那张图是智联的,大概就要这样一个效果
昨天想了半天,简单的实现了这个效果github-有图有真相
思路是用一个List保存数量有限的Fragment,adapter的getCount返回Integer.MAX_VALUE
但是感觉往里传值的时候太麻烦了
请问各位有没有合适的方法实现这个效果
https://github.com/qmr777/Rec...
插不了图片了。。。上面是我的实现
ringa_lee2017-04-17 17:38:22
It would be better if this is not just ViewPager + Fragment
的实现么,只不过他要实现无限滑动的功能罢了。传值还是在不同的Fragment
中传值,当然能优化成一个Fragment
.
阿神2017-04-17 17:38:22
The correct answer upstairs is actually a viewPager. Just write a fragmentStatePagerAdapter and put your list in it. This can control the number of saved fragments and create new fragments.
迷茫2017-04-17 17:38:22
I have done this before, and the implementation method is ViewPager
+Fragment
. The actual content and some details depend on the application logic.
黄舟2017-04-17 17:38:22
My approach is:
Suppose there are three fragments, namely f1, f2, and f3. Then when I initialize the PagerAdapter of ViewPager, a total of 5 fragments are returned. The order is: f3,f1,f2,f3,f1. The default currentItem is 1, which is f1.
Then customize ViewPager.OnPageChangeListener. In the onPageScrollStateChanged method, when the state is IDLE (stopped), if the current currentItem is 0, use setCurrentItem(4, false). If it is 4, use setCurrentItem(1, false).
I believe that smart students will understand my implementation logic.