try this:
public void bindView(final View v, final Context ctx, final Cursor c) {
LinearLayout parent = (LinearLayout) v;
final int position = c.getPosition();
Log.i("MyAdapter", "Cursor position: "+ position
+ "\tImages: "+ (parent.getChildCount() -1));
((TextView) v.findViewById(R.id.content))
.setText(c.getString(c.getColumnIndex(COLUMN_A)));
//use a linear layout defined in the item.xml instead of dynamically create one
LinearLayout ll = (LinearLayout)v.findViewById(R.id.linearlayout);
for (int i=0; i<(position+1); i++) {
SystemClock.sleep(i * 100);
ImageView img = new ImageView(ctx);
img.setImageResource(R.drawable.ic_launcher);
//assign an id to the image to add
int id = i+10000;
img.setId(id);
//check if the image has been already added.
if(ll.findViewById(id) == null){
ll.addView(img);
}
}
}
item.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" >
<TextView android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="30dip"
android:text="---"/>
<LinearLayout
android:id="@+id/linearlayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
EDIT:
you can of course skip the creation of the image and the sleep on next scrolling if you slightly change the for loop like this:
for (int i=0; i<(position+1); i++) {
int id = i+10000;
//check if the image has been already added.
if(ll.findViewById(id) == null){
SystemClock.sleep(i * 100);
ImageView img = new ImageView(ctx);
img.setImageResource(R.drawable.ic_launcher);
//assign an id to the image to add
img.setId(id);
ll.addView(img);
}
}