@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null){
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.country_row, null);
}
Country item = getItem(position);
TextView tv1 = (TextView) v.findViewById(R.id.country);
final CheckedTextView ctv = (CheckedTextView) v.findViewById(R.id.checked);
ctv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ctv.toggle();
Country country = (Country) listView.getItemAtPosition(position);
Log.d("daim", country.getCountry() + " " + country.getCode());
//listView.getCheckItemIds();
}
});
tv1.setText(item.getCountry());
return v;
}
当我检查让我们说第一个元素(位置 0)时,它会被检查,但是当我向下滚动列表视图时,下一个“部分”的第一个位置也会被检查,这一直持续下去。例如,我有 100 个元素,我检查位置 0,然后检查位置 10、20、30、40 等。如何处理这种问题?
提前致谢。