ok i encounter a problem with this custom ArrayAdapter
public class AuthorsAdapter extends ArrayAdapter<Entity> {
View row;
static class ViewHolder {
TextView textViewTitle;
TextView textViewEntitySummary;
ImageView imageViewPicture;
}
public AuthorsAdapter(Context context, LinkedList<Entity> entity) {
super(context, 0, entity);
}
@Override
public View getView( final int position, View convertView, final ViewGroup parent) {
row = convertView;
final ViewHolder holder;
if (row == null) {
row = LayoutInflater.from(getContext()).inflate(R.layout.listview_search_author_template, parent, false);
holder = new ViewHolder();
holder.textViewTitle = (TextView) row.findViewById(R.id.textView_TitleTopLeft);
holder.textViewEntitySummary = (TextView) row.findViewById(R.id.textView_EntitySummary);
holder.imageViewPicture = (ImageView) row.findViewById(R.id.imageView_author);
row.setTag(holder);
} else
holder = (ViewHolder) row.getTag();
holder.textViewTitle.setText(getItem(position).getTitle());
if (!getItem(position).getPictureURL().isEmpty())
Picasso.with(getContext()).load(getItem(position).getPictureURL()).into(holder.imageViewPicture);
holder.textViewEntitySummary.setText(getItem(position).getBiography());
holder.imageViewPicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!getItem(position).isImageResized()) {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
getItem(position).setIsImageResized(true);
} else if (getItem(position).isImageResized()) {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT));
getItem(position).setIsImageResized(false);
} else {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT));
}
}
});
return row;
}
everything works well expected the imageView onclicklistener :
holder.imageViewPicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!getItem(position).isImageResized()) {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
getItem(position).setIsImageResized(true);
} else if (getItem(position).isImageResized()) {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT));
getItem(position).setIsImageResized(false);
} else {
holder.imageViewPicture.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.MATCH_PARENT));
}
}
});
}
i want that the image change it size on click, it work but when i scroll down in my view, random other items in my listView get affected by clicking on first item... and when i come up in my listview the image is not resized anymore (at index where i clicked) any hints to make this working flawlessly?