I have a FragmentStatePager
(or a ViewPager
) and it contains on every page a ListView
.The user should be able to add values dynamically into it.
So my question is :What is the best way to store these entries?
I have a FragmentStatePager
(or a ViewPager
) and it contains on every page a ListView
.The user should be able to add values dynamically into it.
So my question is :What is the best way to store these entries?
You can store the data from the ListView
in an ArrayList
which you can keep track of in the PagerAdapter
.
public class MyPagerAdapter extends PagerAdapter{
private ArrayList<T>[] mData;
@Override
public int getCount() {
return mData.length;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ArrayList<T> listViewData = mData[position];
MyFragment fragment = new MyFragment();
fragment.setData(listViewData);
...
}
}