siralam / LoopingViewPager

A ViewPager and PagerAdapter combination that support auto scroll, infinite loop and page indicators.
532 stars 64 forks source link

ViewPager don't show last item #24

Closed hai199580 closed 4 years ago

hai199580 commented 5 years ago

I have a list of fragment, and i want to bind to my ViewPager, but in last page, it not show my fragment :'(

Here is my Pager Adapter

image

and item_infinity_pager.xml

<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/flContainer" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout>

siralam commented 4 years ago

Hm, I am not very sure if fragment is really supported. But I do see a problem in your code here -

You are using listPosition+1 as the id of the frameLayout. The last item of the list is used twice in the view pager to create the looping effect, so probably there are 2 FrameLayouts with the same id (listPosition of the last item). So probably the fragment is replaced to the hidden one but not the one shown.

Try other ways to assign ID instead of using list Position to see if that solves your problem.