Android: how to use FragmentTransaction.add in a fragment -
so trying add fragment within fragment, told change fragment transaction variable go from:
fragmenttransaction ft = fm.begintransaction();
to
fragmenttransaction ft = getchildfragmentmanager().begintransaction();
however, not sure id use when call ft.add();
previously using android.r.id.content. there similar id can use fragment, or id should use able add new fragment within fragment.
edit:
activity_mainfrag:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mainview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#eeeeee" android:orientation="vertical"> ... </linearlayout>
use add fragment:
fragmenttransaction ft = getchildfragmentmanager().begintransaction(); ft.replace(r.id.container_parent, fragment, fragment.gettagtext()); ft.addtobackstack(fragment.gettagtext()); ft.commit();
Comments
Post a Comment