我正在尝试在删除行后更新ListView。我尝试了很多方法,但它不起作用。我想通过单击删除一行,然后更新列表视图。
这是我的代码:
listView.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
delID = position+1;
//openAlert(v);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilder.setTitle("Delete");
alertDialogBuilder.setMessage("Are you sure want to delete?");
// set positive button: Yes message
alertDialogBuilder.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
mydb.deleteContact(delID);
arrayAdapter.notifyDataSetChanged();
}
});
请帮助我,我渐渐消失了。