I have the problem mentioned in this SO post: Selected list item color moves on scrolling the listView in Android, but I don't understand how to fix this.
This is what it looks like:
The highlight of an item moves over another item that isn't selected (when scrolling). Sometimes the highlight is between 2 items (half and half)..
This bug also happens with default adapter (no adapter set).
This is my Adapter:
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Color;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class SimpleCheckAdapter extends ArrayAdapter<String> {
private SparseBooleanArray mSparseBooleanArray;
private LayoutInflater mInflater;
private ArrayList<String> itemsArrayList;
public SimpleCheckAdapter(Context context, ArrayList<String> a) {
super(context,R.layout.srow,a);
this.itemsArrayList = a;
this.mInflater = LayoutInflater.from(context);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = this.mInflater.inflate( R.layout.srow, parent, false);
}
// 3. Get the two text view from the rowView
TextView txt = (TextView) convertView.findViewById(R.id.simpleText);
// 4. Set the text for textView
txt.setText(itemsArrayList.get(position));
// 5. return rowView
return convertView;
}
}
Who can help and know how to fix this ugly behavior?