When marking an item (changing background color) in ListView it's repeating for other items.
- by Adi
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?