Code example for PagerAdapter

Methods: setPrimaryItem

0
        this.mContext = context;
    } 
 
    @Override 
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
        ((GalleryViewPager)container).mCurrentView = ((UrlTouchImageView)object).getImageView();
    } 
 
    @Override 
    public Object instantiateItem(View collection, int position){
        UrlTouchImageView iv = new UrlTouchImageView(mContext);
//        iv.setUrl(mResources.get(position)); 
        iv.setUrlAndThumbnail(mResources.get(position), "/mnt/sdcard/tgram/image/text_small.png");
        iv.setLayoutParams(new Gallery.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
        ((ViewPager) collection).addView(iv, 0);
        return iv;
    } 
 
    @Override