instantiateItem item method is wrong place to do it. because it doest work for only one view it works for 3 view at same time.
try moving
if (position == 0 && pages == 1) {
setPages(2);
notifyDataSetChanged();
}
if (position == 1 && pages == 2) {
setPages(3);
notifyDataSetChanged();
}
in
setPrimaryItem
Method
UPDATE:
Try to call instantiateItem
method for the position you want in the setPrimaryItem
method. You can do it since instantiateItem
is a public
method.But i have no idea how it is going to work it is a theory. Just give it a try.