J'ai une mise en page demise à jour du fragment avec un nouveau fragment Android
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="wrap_content" >
<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="wrap_content">
<LinearLayout android:id="@+id/linearLayout13" android:layout_height="wrap_content" android:paddingRight="70dp" android:orientation="vertical" android:paddingLeft="70dp" android:layout_width="wrap_content">
<ImageView android:id="@+id/baby_icon" android:layout_height="wrap_content" android:src="@drawable/baby" android:clickable="true" android:layout_width="wrap_content"></ImageView>
</LinearLayout>
</LinearLayout>
<fragment
android:name="com.nicu.health.FragAFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/yellow_cardlist_fragment"
android:layout_weight="1"
>
</fragment>
</LinearLayout>
Au démarrage cela ne montre le fragment correct (FragAFragment). Maintenant sur le bouton cliquez sur baby_icon
J'essaye de supprimer le fragment actuel et d'en ajouter un nouveau (FragBFragment) qui a une disposition entièrement différente.
Bien que je vois que la méthode onCreateView
est appelée et qu'elle renvoie une vue non null mais l'interface utilisateur sur l'écran du nouveau fragment n'est pas mise à jour. J'utilise le code ci-dessous pour mettre à jour le fragment. J'avais essayé toutes les combinaisons d'enlever, remplacer et ajouter pour obtenir le fragment de travail, mais en vain!
également d'autres j'ai essayé avec le code comme
<fragment
android:name="com.nicu.health.FragBFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/yellow_cardlist_fragment"
android:layout_weight="1"
>
et cela ne fonctionne pour montrer le second fragment au démarrage !!!!
L'aide sera vraiment appréciée.
Merci,