Each layout of the flipperview will be the same as this- flippercontainter.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1" >
<ImageView
android:id="@+id/imgView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.3"
android:padding="10dp" />
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Name of product"
android:textColor="#31B6E7"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtCaf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="40dp"
android:text="$" />
</LinearLayout>
On the activity with the viewflipper:
private void setFlipperContent() {
List<Stuff> aux=getStuffList();
end = aux.size();
for (int i = 0; i < end; i++) {
LayoutInflater inflater = (LayoutInflater) this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.flippercontainer, null);
flipper.addView(view);
image = (ImageView) view.findViewById(R.id.imgView);
image.setBackgroundResource(aux.get(i).getImg());
name = (TextView) view.findViewById(R.id.txtName);
name.setText(aux.get(i).getName());
cafPrice = (TextView) view.findViewById(R.id.txtCaf);
cafPrice.setText("$" + aux.get(i).getCafPrice());
}
setFlipperAnimation();
}