这是我的上下文菜单中的删除调用:
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
.getMenuInfo();
int clickedPosition = info.position;
tvInt = reviews.get(clickedPosition);
switch (item.getItemId()) {
case R.id.Delete:
new DeleteCommentTask().execute();
reviews.remove(clickedPosition);
adapter.notifyDataSetChanged();
Toast.makeText(getActivity(), "Review Deleted",
Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
我确实验证了在我的 DeleteCommentTask 中它确实从我的数据库中删除了评论。但是 ListView 没有更新?
更新:这是我正在使用的适配器:
MyReviewObject co = new MyReviewObject[reviews.size()];
int index = 0;
for (@SuppressWarnings("unused")
String i : reviews) {
co[index] = new MyReviewObject(datelist.get(index),
reviews.get(index), items.get(index),
cats.get(index));
index++;
}
adapter = new MyReviewAdapter(getActivity(), co);
setListAdapter(adapter);