My issue is item is deleted from the list view and after deleting when I press back button and again going to list same deleted item is coming. I have also added my code in below. Please help me on this issue and save my time.
// in Activity
lstMembers.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, final int position, long l) {
new AlertDialog.Builder(GroupInfoActivity.this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setMessage("Are You Sure You Want to Delete This Note?!")
.setTitle("Attempt to Delete A Note")
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try {
if(groupMemberAdapter!=null){
groupMemberAdapter.removeObject(position);
groupMemberAdapter.notifyDataSetChanged();
Toast.makeText(GroupInfoActivity.this, "ooooooh No!!", Toast.LENGTH_SHORT).show();
}
}catch (Exception e){
e.printStackTrace();
}
}
})
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(GroupInfoActivity.this, "Good Choice", Toast.LENGTH_SHORT).show();
}
})
.show();
return true;
}
});
//in Adapter
public void removeObject (int position) {
this.groupMemberList.remove(position);
}
public void removeObject (int position) {
this.groupMemberList.remove(position);
}
This looks like you're deleting it only in-memory, but you have to remove it from the database/ from wherever it comes to make it not show up again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.