Android: remove() Fragment--> add() new Fragment of same class again ->onCreateView and onActivityCreated not called?

Viewed 4084

I am destroying a programmatically created fragment with:

getFragmentManager().beginTransaction().remove(getFragmentManager().findFragmentById(R.id.test)).commit();

Which is determined in the xml file like this:

<LinearLayout
    android:id="@+id/test"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

</LinearLayout>

If I then create a fragment from the same class again in the mainactivity:

getSupportFragmentManager().beginTransaction()
            .add(R.id.result_bar, testinstance)
            .commit();

Then onCreate seem not called again (the fragment is just empty). What am I doing wrong here? Thanks.

1 Answers
Related