i have an app with many fragments. this is layout on horizontal mode:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="com.map.manager.ListUser"
android:id="@+id/listuser_fragment"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
<fragment android:name="com.map.manager.DetailApp"
android:id="@+id/detailapp_fragment"
android:layout_weight="2"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>
i can see my fragments correcty but if i do this:
DetailUser appFrag = (DetailUser)
getSupportFragmentManager().findFragmentById(R.id.detailuser_fragment);
if (appFrag != null) {
// If article frag is available, we're in two-pane layout...
// Call a method in the ArticleFragment to update its content
appFrag.updateAppointmentView(position);
}
else {
DetailUser dtuser = new DetailUser();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.detailapp_fragment, dtuser);
transaction.commit();
i can replace fragments but i can see old fragment into backgroud.. i read THIS i can't replace static fragments but how add it dynamically? (more than one into horizontal mode..) Can i replace a fragment without knowing old fragment?