I create adapter when click on Item in activity. The first page is empty. When I slide it over (to the third page content there is present) and come back content is there.
public void showItem(){
mSwipeAdapter = new SwipeAdapter(mItemsList);
mSwipePager.setAdapter(mSwipeAdapter);
this.setVisibility(View.VISIBLE);
}
And adapter
private class SwipeAdapter extends PagerAdapter {
List<Item> mSwipeItems;
public SwipeAdapter(List<Item> mItems) {
mSwipeItems = mItems;
}
@Override
public int getCount() {
return mSwipeItems.size();
}
public Object instantiateItem(ViewGroup collection, int position) {
mCurrentContentView = new ContentView(mContext);
mCurrentItem = mSwipeItems.get(position);
mCurrentContentView.showItem(mCurrentItem);
collection.addView(mCurrenContentView);
return mCurrentContentView;
}
@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == ((View) arg1);
}
@Override
public Parcelable saveState() {
return null;
}
}
I find here the same problem First viewpager page blank but there no solution.