I can remove and add fragments, but replace doesn't cause the new
Fragment to show up.

The API docs are a little unclear about which existing Fragment would
be replaced.

On Mar 23, 4:49 pm, jotobjects <jotobje...@gmail.com> wrote:
> Having a bit of a go with Fragments and hitting a snag.  My layout
> looks like this.  The objective is to add a Fragment to the
> LinearLayout.
>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:id="@+id/foobar"
>     android:layout_width="fill_parent"
>     android:layout_height="wrap_content"
>     android:orientation="vertical"
> />
>
> First I do this - which works fine to add and display the Fragment
> into the layout container
>
> Fragment f1 = new FragmentOne();
> fragmentManager.beginTransaction().add(R.id.foobar, f1,
> "ABC").commit();
>
> later on I want to replace that Fragment with a different one so I do
> this -
>
> Fragment f2 = new FragmentTwo();
> fragmentManager.beginTransaction().replace(R.id.foobar, f2,
> "DEF").commit();
>
> But Fragment f1 is still there in the View. What part of this is am I
> doing incorrectly?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to