There is a listview on 1 tab, a to-do list. press case 1, opens tab2 on it opens the Monday fraction, enter data, press the button next, the values ​​from the fields are saved in the database, the fragment opens on Tuesday, too, the fields, the checkbox, we do the same on such fragments 7. and there is a tab3 there is a list of tasks they are filled with status or not, and when you click on a case, the last data fragment should open. The task is this: I chose a case, started filling it out and then switched to tab 3, and decided to fill out another case, click and go to the last fragment. how best to implement it? Option 1. When switching tabs, put a method that will read the contents of all fields and update the values ​​in the database, and when clicking on a case, it will check the contents of the cell and then restore the entered values ​​and the fragment itself, but this method has a minus since it does not save the backstack itself fragments, option 2 for each element. write custom Stack Fragment to put fragments in it, when switching all this stack to serialize and push in the database? but something is too dreary. tell me how best to do? Implemented this class:

public class SimpleFragmentManager { private Stack<Fragment> fragmentStack; public SimpleFragmentManager() { fragmentStack = new Stack<>(); } public void push(Fragment fragment) { fragmentStack.push(fragment); } public void reset(Fragment fragment) { fragmentStack.empty(); fragmentStack.push(fragment); } public Fragment pop() { return fragmentStack.pop(); } public Fragment peek() { return fragmentStack.peek(); } } 

and use it like this:

  public void nextStep() { Monday monday = new Monday(); FragmentManager manager = getFragmentManager(); FragmentTransaction ft = manager.beginTransaction(); ft.replace(R.id.leftcontent, monday); simpleFragmentManager.push(checkData); //ft.addToBackStack("monday"); ft.commit(); } public void backStep() { simpleFragmentManager.pop(); /*FragmentManager manager = getFragmentManager(); manager.popBackStack();*/ } 

but in general it doesn’t work out To show the scheme more clearly: to-do list:

 дело 1 Fragment1-->fragment2-->fragment3 дело 2 Fragment1-->fragment2 дело 3 Fragment1-->fragment2-->fragment3-->fragment4 

and it turns out that when switching tabs you need to save the chain for each case, how is this done?

    0