3

I have been trying to hide/show fragment and add another fragment. This is xml

<FrameLayout
        android:id="@+id/frag_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

            <fragment
        class="com.tugce.MitsActionBar.KartvizitFragment"
        android:id="@+id/frag_kartvizit"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />
        </FrameLayout>

After calling something else and calling this fragment again, its mAdded property is false so when i tried to access getView() it is null.

I tried every edit in this post: Android Honeycomb: How to change Fragments in a FrameLayout, without re-creating them? But still cannot manage to make it work.

Community
  • 1
  • 1
tugce
  • 651
  • 3
  • 13
  • 28

1 Answers1

1

You can add android:visibility flag to the parent layout (in this case framelayout) of the fragment inside xml and use that in your java code.

Vamsi
  • 878
  • 1
  • 8
  • 25