The object returned should not be the View
, but the object used to identify the View
. In this case, the position is being used as an index, so the return value should be position:
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0.getTag().equals(arg1);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView view = new ImageView(container.getContext());
view.setScaleType(ScaleType.FIT_CENTER);
view.setTag(position);
view.setImageResource(mImages.get(position));
container.addView(view, position);
return position;
}