Sangeeta Sangeeta - 1 year ago 91
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.


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 Source

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

Thanks to :

ViewPager inside fragment, how to retain state?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download