Android fragment reuse layout created in onCreateView again?

I think yes, you need to create new instance, because you save the context in the fragment. This is the IllegaleStateException,for example you get the same exception if you called twice the setContentView() method. Maybe you call removeView() or removeAllViews() it will works.

I create my layout in the onCreateView of the Fragment (say FragA) the first time it is called and store it in a member variable (say ViewA). Now I push another fragment (say FragB) on top of it and after some work press the back button. This causes the FragA'a onCreateView to be called again.

Now if I return my saved member Variable (ViewA) then an exception is thrown saying 'The specified child already has a parent. You must call removeView() on the child's parent first'.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions