单击列表视图中的复选框时,如何从 sdcard 中的特定文件夹中删除特定文件。
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = null;
if (convertView == null) {
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(R.layout.rowbuttonlayout, null);
final ViewHolder viewHolder = new ViewHolder();
viewHolder.text = (TextView) view.findViewById(R.id.label);
viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check);
viewHolder.imageView=(ImageView) view.findViewById(R.id.imageView1);
viewHolder.imageView.setImageResource(R.drawable.ic_launcher);
viewHolder.checkbox.setChecked(true);
viewHolder.checkbox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("checkeddddd","checkedddddd2222222233333333444444");
}
});
viewHolder.checkbox
.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
Model element = (Model) viewHolder.checkbox
.getTag();
element.setSelected(buttonView.isChecked());
InterectiveArrayAdapter.this.remove(InterectiveArrayAdapter.this.getItem(position));
//adapter.notifyDataSetChanged();
// list.remove(position);
Toast.makeText(getContext(), "Checked",
Toast.LENGTH_SHORT).show();
}
});
view.setTag(viewHolder);
viewHolder.checkbox.setTag(list.get(position));
} else {
view = convertView;
((ViewHolder) view.getTag()).checkbox.setTag(list.get(position));
Log.i("checkeddddd","checkedddddd2222222233333333");
}
ViewHolder holder = (ViewHolder) view.getTag();
holder.text.setText(list.get(position).getName());
holder.checkbox.setChecked(list.get(position).isSelected());
return view;
}
这是我的适配器类我已经自定义了我的适配器类并且我已经在适配器类中放置了复选框以显示在列表视图中并且列表视图中的数据来自 sdcard 中的文件夹我需要检查一个特定的复选框并单击按钮然后应该从 sdcard 的文件夹中删除该特定文件。我该怎么做???