I'm trying to save the data of forms contained in a viewpager
.When I'm in landscape
mode it works perfectly but when I rotate the screen all the data are gone and the fields are blank again.How to deal with that ?
The fragment in which I call the viewpager :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_main,
container, false);
mViewPager = (ViewPager)rootView.findViewById(R.id.pager);
mAdapter = new MyFragmentPagerAdapter1(getChildFragmentManager());
mViewPager.setOffscreenPageLimit(6);
new setAdapterTask().execute();
return rootView;
}
private class setAdapterTask extends AsyncTask<Void,Void,Void>{
protected Void doInBackground(Void... params) {
return null;
}
@Override
protected void onPostExecute(Void result) {
mViewPager.setAdapter(mAdapter);
}
}
adpater :
@Override
public Fragment getItem(int arg0) {
switch (arg0) {
case 0:
Part1 p1= new Part1();
p1.setRetainInstance(true);
return p1;
case 1:
return new part2();
default:
return null;
}
}