我正在使用这一法典来这样做,但现在该法典并没有发挥作用。 我可以选择检查箱,当我点击 but子时,没有发生。
SimpleAdapter adapter;
List<HashMap<String, String>> painItems = new ArrayList<HashMap<String, String>>();
ListView listthings;
...
cb = (CheckBox)findViewById(R.id.checkBox1);
adapter = new SimpleAdapter(this, painItems, R.layout.mylistlayout,
from, to);
listthings.setAdapter(adapter);
listthings.setOnItemClickListener(this);
deleteButton = (Button) findViewById(R.id.deleteButton);
deleteButton.setOnClickListener(this);
...
public void onClick(View v) {
if (v == this.deleteButton) {
// Toast.makeText(this, "delete clicked", Toast.LENGTH_SHORT).show();
deleteCheckedItems();
}
}
...
private void deleteCheckedItems() {
int count = this.listthings.getAdapter().getCount();
for (int i = 0; i < count; i++) {
if (this.listthings.isItemChecked(i)) {
painItems.remove(i);
adapter.notifyDataSetChanged();
listthings.invalidateViews();
}
}
感谢任何帮助。 感谢 你提前。