I am creating an app in which i can fetch files from sdcard and delete it, for deleting files I'm using checkbox but when I'm scrolling it's state gets changed. How can i check if that file is checked or not? Should i create setters and getters for it?
@Override
public View getView(final int position, View convertView, ViewGroup parent)
{
// TODO Auto-generated method stub
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
convertView = inflater.inflate(R.layout.row, parent, false);
final CheckBox cb = (CheckBox) convertView.findViewById(R.id.checkBox1);
TextView tv = (TextView) convertView.findViewById(R.id.textView1);
tv.setText(modelItems.get(position));
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton p1, boolean isChecked)
{
// TODO: Implement this method
if (p1.isChecked())
{
isChecked = true;
cb.setChecked(true);
}
else
{
isChecked = false;
cb.setChecked(false);
}
}
});
return convertView;
}
Aucun commentaire:
Enregistrer un commentaire