我需要在带有复选框的单独列表视图中显示数据。在那我检查了一些视图,但是当我滚动时,选中状态变为未选中。我正在使用以下类来显示我的列表视图。
public class SearchAdapter extends ArrayAdapter<Map<String,?>>{
private LayoutInflater inflater;
private int resId=0;
private List<Map<String,?>> listitem;
public SearchAdapter(Context context, int resId, List<Map<String,?>> dataList){
super(context, 0, dataList);
this.resId = resId;
inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.listitem = dataList;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view;
TextView code,date; CheckBox checkbox;
view = inflater.inflate(resId, parent, false);
code = (TextView)view.findViewById(R.id.code);
date= (TextView)view.findViewById(R.id.date);
checkbox=(CheckBox)view.findViewById(R.id.check);
Map<String,?> item = listitem.get(position);
final String[] values=(String[]) item.get("values");
checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Integer pos = (Integer)buttonView.getTag();
if(isChecked)
{
Log.e("checked","checked"+position);
} else{
Log.e("checked","unchecked");
}
}
});
code.setText(values[32]);
date.setText(values[31]);
return view;
}
}
我的屏幕视图
所以,请指导我,如何克服这个问题