Skip to content Skip to sidebar Skip to footer

Android: Saving Form Data On A Swipe Rather Than From A Button

I am very new to android and this is my second app. I am making a tabbed activity where the first fragment has a form to create a new task, the second fragment has the list of all

Solution 1:

The invoked method for a page change(when another page gets selected) in your OnPageChangeListener is onPageSelected.

Also, calling getItem on your PagerAdapterinstantiates a new Fragment. To solve this problem, you'll need to keep a List of your Fragments in your PagerAdapter and create a method to retrieve them.

//in PagerAdapter:private List<Fragment> fragmentList;

publicSectionsPagerAdapter(FragmentManager fm) {
    super(fm);
    fragmentsA = fragments;
    fragmentList = new ArrayList<Fragment>();

    for(int i = 0; i < 3; i++){
        fragmentList.add(Fragment.instantiate(getApplicationContext(), fragmentsA.get(i)););
    }
}

public Fragment getFragment(int position){

    return fragmentList.get(position);
}

Post a Comment for "Android: Saving Form Data On A Swipe Rather Than From A Button"