When marking an item (changing background color) in ListView it's repeating for other items.
Posted
by Adi
on Stack Overflow
See other posts from Stack Overflow
or by Adi
Published on 2010-05-30T18:18:13Z
Indexed on
2010/05/30
18:22 UTC
Read the original article
Hit count: 216
If I want to mark the second item I'm doing the following code: This code is from my Adapter that extends ArrayAdapter :
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.channel_list, null);
}
MyContent o = items.get(position);
if (o != null) {
TextView tt = (TextView) convertView.findViewById(R.id.toptext);
TextView bt = (TextView) convertView.findViewById(R.id.bottomtext);
if (tt != null) {
tt.setText(o.Top());
}
if(bt != null){
bt.setText(o.Bottom());
}
if(position == 2) {
convertView.setBackgroundColor(R.color.selectem_color);
}
}
return convertView;
It will show the list view but mark every 9'th item after this item (the 11'th item 13'th and so on).
Does anyone know what's the reason?
© Stack Overflow or respective owner