I am writing an application where I using PageViewer to show infinite client using solution available here.
In my case I have to update this already added child from other event say from [onPageState][2], using following code:
PageFragment scr = (PageFragment) mPagerAdapter.getItem(mPager.getCurrentItem());
but it returning IllegalStateException that say, Fragment already Active.
I checked with this but I am not getting it.
EDIT: Fragment child add code: It's at very beginning, I create first list of fragment:
for (int i = 0; i < 5 ; i++) {
PageFragment fragment = new PageFragment();
Bundle bundle = new Bundle();
bundle.putInt("page", i);
fragment.setArguments(bundle);
pageList.add(fragment);
}
EDIT2: Here the line fragment.setArguments(..) causing error, why?
and this is adapter implementation:
private class PagerAdapter extends FragmentStatePagerAdapter {
public PagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
int _pos = position % 5;
PageFragment fragment = pageList.get(_pos);
Bundle bundle = new Bundle();
bundle.putInt("page", position);
fragment.setArguments(bundle);
return fragment;
}
@Override
public int getCount() {
return MAX_CARD_PAGES;
}
}
Any suggestion.