0

I have few fragments attached to one activity.I want to retreive the fragment from the stack if your exsists in the collection/stack.And i do not want to pop out or loose the fragment once it loaded.I want to reuse the same fragment all time when needed.

  1. Is there any way i can use fragment manager and achieve this ?

or

  1. can i maintain my own hashMap of fragments and implement it ?

Using 2 way, i tried doing it,i am getting exception.

I'm trying to use fragmemt.getView() and attached the view to the frameLayout and the exception is thrown as shown :

layout.addView(fragment.getView());

09-29 09:16:24.887    3481-3481/com.sample.android.app W/System.err:   
java.lang.IllegalStateException: The specified child already has a parent. You must call     
removeView() on the child's parent first.

Note: I cannot pop fragment as i ll loose the fragment.I just want to reuse the same fragment all time to avoid loading data.

Meher
  • 2,545
  • 3
  • 26
  • 53

0 Answers0