J'ai 5 pages de xml qui sont assez complexes. Je veux mettre les 5 pages dans un ViewPager. Tous les échantillons que je peux trouver mettent simplement le contenu identique dans chaque page par l'intermédiaire du code. Je veux définir de manière déclarative le xml dans le viewpager comme le xml collé ci-dessous. Mais cela ne fonctionne pas - l'application s'arrête avec ce fichier XML.Définition de fragments dans ViewPager de manière déclarative
Si je ne peux pas le définir de manière déclarative, puis-je charger des pages xml individuelles dans le viewpager? Je ne peux trouver aucun exemple qui le fasse. merci, Gary Blakely
<?xml version="1.0" encoding="utf-8"?>
<fragment >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/imageView1"
android:src="@drawable/flashright" android:adjustViewBounds="true" android:scaleType="fitXY">
</ImageView>
</LinearLayout>
</fragment>
<fragment >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/imageView1"
android:src="@drawable/flashleft" android:adjustViewBounds="true" android:scaleType="fitXY">
</ImageView>
</LinearLayout>
</fragment>
C'était un mauvais travail de collage de code - que xml était dans un viewpager. J'ai fini par gonfler les différents fichiers XML dans le code. Je suis nouveau sur Android et habitué à XAML où nous pouvons faire n'importe quoi de façon déclarative. –