package com.celerysoft.imagepagerdemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.celerysoft.imagepager.ImagePager;
import com.celerysoft.imagepager.adapter.ImagePagerAdapter;

import java.util.ArrayList;

import uk.co.senab.photoview.PhotoView;

/**
 * Created by Administrator on 2015-11-18.
 */
public class MainActivity extends Activity {
    private ImagePager mImagePager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        mImagePager = (ImagePager) findViewById(R.id.main_image_pager);

        ImagePagerAdapter adapter = new ImagePagerAdapter();
        ArrayList<PhotoView> photoViews = new ArrayList<>();
        PhotoView v1 = new PhotoView(this);
        v1.setImageResource(R.drawable._00001);
        PhotoView v2 = new PhotoView(this);
        v2.setImageResource(R.drawable._00002);
        PhotoView v3 = new PhotoView(this);
        v3.setImageResource(R.drawable._00003);
        photoViews.add(v1);
        photoViews.add(v2);
        photoViews.add(v3);
        adapter.setImageViews(photoViews);

        mImagePager.setAdapter(adapter);
        //mImagePager.setAdapter(new SamplePagerAdapter());
    }

    static class SamplePagerAdapter extends PagerAdapter {

        private static final int[] sDrawables = { R.drawable._00001, R.drawable._00002, R.drawable._00003 };

        @Override
        public int getCount() {
            return sDrawables.length;
        }

        @Override
        public View instantiateItem(ViewGroup container, int position) {
            PhotoView photoView = new PhotoView(container.getContext());
            photoView.setImageResource(sDrawables[position]);

            // Now just add PhotoView to ViewPager and return it
            container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

            return photoView;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

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

    }
}

@@ -301,37 +301,8 @@
 r;%0A%0A
-import java.util.ArrayList;%0A%0A
 impo
@@ -771,236 +771,80 @@
 ter(
-);%0A        ArrayList%3CPhotoView%3E photoViews = new ArrayList%3C%3E();%0A        PhotoView v1 = new PhotoView(this);%0A        v1.setImageResource(R.drawable._00001);%0A        PhotoView v2 = new PhotoView(this);%0A        v2.setImageResource(
+this);%0A        int%5B%5D imageResIds = new int%5B3%5D;%0A        imageResIds%5B0%5D = 
 R.dr
@@ -855,18 +855,17 @@
 le._0000
-2)
+1
 ;%0A      
@@ -870,475 +870,68 @@
     
-PhotoView v3 = new PhotoView(this);%0A        v3.setImageResource(R.drawable._00003);%0A        photoViews.add(v1);%0A        photoViews.add(v2);%0A        photoViews.add(v3);%0A        adapter.setImageViews(photoViews);%0A%0A        mImagePager.setAdapter(adapter);%0A        //mImagePager.setAdapter(new SamplePagerAdapter());%0A    %7D%0A%0A    static class SamplePagerAdapter extends PagerAdapter %7B%0A%0A        private static final int%5B%5D sDrawables = %7B R.drawable._00001, R.drawable._00002,
+imageResIds%5B1%5D = R.drawable._00002;%0A        imageResIds%5B2%5D =
  R.d
@@ -948,21 +948,18 @@
 0003
- %7D
 ;%0A
-%0A
         
 @Ove
@@ -958,842 +958,86 @@
     
-@Override%0A        public int getCount() %7B%0A            return sDrawables.length;%0A        %7D%0A%0A        @Override%0A        public View instantiateItem(ViewGroup container, int position) %7B%0A            PhotoView photoView = new PhotoView(container.getContext());%0A            photoView.setImageResource(sDrawables%5Bposition%5D);%0A%0A            // Now just add PhotoView to ViewPager and return it%0A            container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);%0A%0A            return photoView;%0A        %7D%0A%0A        @Override%0A        public void destroyItem(ViewGroup container, int position, Object object) %7B%0A            container.removeView((View) object);%0A        %7D%0A%0A        @Override%0A        public boolean isViewFromObject(View view, Object object) %7B%0A            return view == object;%0A        %7D%0A
+adapter.setImageResIds(imageResIds);%0A%0A        mImagePager.setAdapter(adapter);
 %0A   

update demo