Whenever I click the ImageView which has a OnClickListener, I get the URL of that object that is meant for the next View on the bottom of my screen, that has yet to get on the screen.
public View getView(int position, View convertView, ViewGroup parent){
View rowView = convertView;
if(rowView == null){
rowView = inflater.inflate(R.layout.listitem, null);
//Creëer een Viewholder om alles statisch op te slaan in het geheugen
holder = new ViewHolder();
holder.title = (TextView) rowView.findViewById(R.id.title);
holder.subreddit = (TextView)rowView.findViewById(R.id.subreddit);
holder.source = (TextView)rowView.findViewById(R.id.source);
holder.score = (TextView)rowView.findViewById(R.id.score);
holder.image = (ImageView)rowView.findViewById(R.id.imageView1);
holder.image.setTag(position);
rowView.setTag(holder);
}
else{
holder = (ViewHolder) rowView.getTag();
}
holder.image.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent i = new Intent();
i.setAction("com.tolgap.json.TEST");
i.putExtra("page", holder.thing.url);
context.startActivity(i);
}
});
holder.thing = gegevens.get(position).data;
holder.title.setText(holder.thing.title);
holder.subreddit.setText(holder.thing.subreddit);
holder.source.setText(holder.thing.domain);
holder.score.setText(holder.thing.score);
holder.image.setImageBitmap(plaatjes.get(position));
return rowView;
}
And here is the code for the ViewHolder:
static class ViewHolder{
Result thing;
TextView title;
TextView subreddit;
TextView source;
TextView score;
ImageView image;
}
I’ve read a few things about using the setTag() method, and I’ve tried this, but I didn’t quite get what I had to put as a tag.
There is no point in storing the
Resultdata object in theViewHolder:The
getView()method: