I have a ListView with an XML view for each of the rows.
On each row there is a ViewFlipper and a Button, the intention being to press the button and flip through the views on the ViewFlipper.
The problem is I can not get the Button to flip the correct ViewFlipper. I am setting the row up in the ListView adapter so I assume this is where I should handle the button click.
Although the click is being handled, the ViewFlipper being 'flipped' is on a different row. I assume this is because the adapter is recycling the views - I just can not work out how to resolve this.
My code is
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mLayoutInflater.inflate(mLayout, null);
viewHolder = new ViewHolder();
viewHolder.flipper = (ViewFlipper) convertView.findViewById(R.id.viewConfFlipper1);
viewHolder.v2FieldName = (TextView) convertView.findViewById(R.id.tvLongName);
viewHolder.button01 = (ImageButton) convertView.findViewById(R.id.imageButton1);
viewHolder.button01.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
viewHolder.flipper.showNext();
}
});
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
viewHolder.v2FieldName.setText(items.get(position).get("name"));
return convertView;
}
Any help appreciated