package com.cky.learnandroiddetails.ViewPagerTest;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.ArrayList;

/**
 * Created by cuikangyuan on 2017/7/24.
 */

public class MyViewPagerAdapter extends PagerAdapter {

    private ArrayList<ImageView> viewList = new ArrayList<>();

    private MyViewPagerAdapter(ArrayList<ImageView> viewList) {
        this.viewList = viewList;
    }

    @Override
    public int getCount() {
        //设置成最大 用户看不到边界
        return Integer.MAX_VALUE;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        //super.destroyItem(container, position, object);
        //不需要在此处removeView
    }
}

@@ -147,16 +147,48 @@
 wGroup;%0A
+import android.view.ViewParent;%0A
 import a
@@ -923,11 +923,529 @@
 ew%0A    %7D
+%0A%0A    @Override%0A    public Object instantiateItem(ViewGroup container, int position) %7B%0A%0A        position %25= viewList.size();%0A        if (position %3C 0) %7B%0A            position = viewList.size() + position;%0A        %7D%0A%0A        ImageView view = viewList.get(position);%0A%0A        ViewParent viewParent = view.getParent();%0A        if (viewParent != null) %7B%0A            ViewGroup viewGroup = (ViewGroup) viewParent;%0A            viewGroup.removeView(view);%0A        %7D%0A%0A        container.addView(view);%0A%0A        return view;%0A    %7D
 %0A%7D%0A

modify viewpager test