Remove method from FragmentTransaction does not remove fragment from container

I have the following problem:

My application should navigate the scoreboard as follows:

+----+-------+    +----+-------+    +----+-------+    +----+-------+
|    |       |    |    |       |    |    |       |    |    |       | 
|  1 |   2   | -> |  2 |  3    | -> | 3  |  4    | -> | 4  |  ...  |
|    |       |    |    |       |    |    |       |    |    |       |
+----+-------+    +----+-------+    +----+-------+    +----+-------+

I tried to make this navigation using FRAGMENTS, since the navigation is dynamic, and I don't know how many levels this navigation will have.

Using the API fragments, I created the following structure to help in the tests by calling the same fragment several times:

If the left panel is empty, insert a fragment into it. If the left panel is not empty and the right panel is empty, insert the fragment in the right panel. If the two panels are not empty, delete a fragment of the right panel and replace the left panel with it. Then insert the new fragment to the right.

, " " replace.

Remove : " . , ".

, API, , : mFragmentId.

- reset ?

+5
2

, :

.

, .

, :

Frag1 frag1 = new Frag1();
frag1.setText("Fragment " + Integer.toString(navigation));
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
if (navigation > 2) {
    ft.remove(fm.findFragmentByTag("f" + Integer.toString(navigation - 2)));
}
ft.add(R.id.Panes, frag1, "f" + Integer.toString(navigation));
if (navigation > 1) {
    ft.addToBackStack(null);
}
ft.commit();

BackStack, , .

, , , , .

ft.hide(fm.findFragmentByTag("f" + Integer.toString(navigation - 2)));

.

+2

, , , (.. ). , , .

0

All Articles