Comment définir des images dynamiques à ViewFlipper dans android?
Je suis en train de faire comme-ci elle est en cours de chargement statique de ces images?
public class ArchiveGroup extends Activity {
Button btn;
ViewFlipper flip;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
btn=(Button)findViewById(R.id.btn);
flip=(ViewFlipper)findViewById(R.id.flip);
}
public void ClickHandler(View v)
{
flip.showNext();
}
public void ClickHandler1(View v)
{
Toast.makeText(this,"text",Toast.LENGTH_LONG).show();
}
}
je suis à l'aide de trois imageview dans ViewFlipper dans xml
fichier
<?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="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Flip"
android:id="@+id/btn"
android:onClick="ClickHandler"
/>
<ViewFlipper
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/flip"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
</ViewFlipper>
</LinearLayout>
Comment mettre des images dynamiques de ces imageView. En utilisant une seule ImageView.
source d'informationauteur sai
Vous devez vous connecter pour publier un commentaire.
Dans votre xml juste ajouter que ce,
n'a pas besoin de joindre, à tout ImageViews.
Désormais le faire dans votre code.
Considérant que vous avez stocké vos Images dans un tableau comme ceci,
Maintenant dans votre onCreate(),
Et maintenant, ajoutez cette méthode à votre activité,
Que c'est. Et maintenant, en utilisant votre
viewFlipper.showNext();
etviewFlipper.showPrevious();
méthodes que vous pouvez montrer à vos images dynamiques.