tugce
tugce

Reputation: 661

how to hide/show fragment defined in xml

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.

Upvotes: 3

Views: 756

Answers (1)

Vamsi
Vamsi

Reputation: 878

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.

Upvotes: 1

Related Questions