i need to display data in separated list view with check boxes. In that i checked some views, but when i am scrolling, the checked state changed to unchecked. i am using the following class to display my listview.
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;
}
}
my screen view
So, please guide me , how to overcome this issue