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.
- Is there any way i can use fragment manager and achieve this ?
or
- 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.