Hello, I need to create a dynamic viewFlipper with 12 ImagesView ie when loading the activity I need this Flipper to load the images for me. Here is my code:
No XML
<ViewFlipper
android:id="@+id/rflipper"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:gravity="center"
android:layout_gravity="top"
android:autoStart="false"
android:background="#f5f5f5"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:visibility="visible">
</ViewFlipper>
In Activity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resultado);
int images[] = R.drawable.imv1, R.drawable.imv2, R.drawable.imv3, R.drawable.imv4, R.drawable.imv5, R.drawable.imv6, R.drawable.imv7, R.drawable.imv8, R.drawable.imv9, R.drawable.imv10, R.drawable.imv11, R.drawable.imv12};
vFlipper = (ViewFlipper) findViewById(R.id.rflipper);
vFlipper.setInAnimation(this, android.R.anim.fade_in);
vFlipper.setOutAnimation(this, android.R.anim.fade_out);
for(int i=0;i<images.length;i++)
{
setFlipperImage(images[i]);
}
vFlipper.setAutoStart(true);
vFlipper.setFlipInterval(4000);
vFlipper.showNext();
}
private void setFlipperImage(int res) {
Log.i("Set Filpper add", res+"");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
vFlipper.addView(image);
}
When I test this code it does not show any errors, it just does not show the Flipper, so it does not show the images. I imagine it's missing to show some FLipper view or show to show it, but I do not know how to do it. Thanks in advance.