Kim Kim - 1 month ago 16
Android Question

In FragmentTabhost, the fragment can`t destory which called by beginTransaction().replace

My fragmentTabhost include 4

fragments(FragmentA,FragmentB,FragmentC,FragmentD)
in the FragmentTabhost .

In FragmentA, I use the code:

getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, Fragment_a1).commitAllowingStateLoss();


to jump to the Fragment_a1(not in the tabhost).

But I found a bug when switching the fragment.Such like this order:
FragmentA->Fragment_a1->FragmentB->FragmentA
.

When switch to the FragmentA after this order,the screen shows the Fragment_a1 (It should show the FragmentA). Printing the logcat I found the Fragment_a1 can`t be destoryed when switch to FragmentB.

Please give me a hand .Thanks!

Kim Kim
Answer

Now I have another method to solve this problem after reading the answer @ How to make particular tab in FragmentTabHost has multiple fragment navigations like tabgroupactivity