Sangeeta Sangeeta - 1 month ago 7
Android Question

Fragment is showing but not attached to activity

Hi i am working in an app, in which:


  1. View pager is there on an activity.

  2. On that view pager i am showing 2 fragments(frag1 and frag2).

  3. on button click on frag1 we have added one more fragment(lets say frag3).

  4. and on back press on frag3 i come back on frag1.



Issue:

the issue is when i come back to frag1 from frag3 on back press, sometimes frag1 is not attached to the activity.

i am not able to figure out how this is happening.

if this is happening then what is the solution so i can stop activity to detach the frag1 or re-initialize the frag1 again.

Please help.

Answer

After searching so much for this issue, finally got an answer to fix this.

Thanks to :

ViewPager inside fragment, how to retain state?

Comments