我正在创建一个应用程序,我可以从sdcard中获取文件并将其删除,删除我正在使用的文件复选框,但是当我滚动时,状态会发生变化。 如何检查该文件是否已被选中?我应该为它创建setter和getter吗?
@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;
}