I am trying to figure out how I \"Refresh\" the list view the user is on when an item from my listview is deleted. I have tried notifyDataSetChanged() but to no avail, which is
Your item is being deleted from database but the listview is not updating visually.Setting adapter is a solution but it will reset the list from start which not make a good experience for user to scroll all the time again.You can do one thing when you removing item from database at the same time you can remove selected item from your list. I think your listview listener should look like this in your activity:
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view,
int position, long id) {
deleteButtonClicked(postion);
}
});
public void deleteButtonClicked(int position){
int count=dbHandler.deleteExerciseFromDatabase(exerciseClickedbyUser, workoutClicked);
if(count>0){
list.remove(position);
edsAdapter.notifyDataSetChanged();
Toast.makeText(getBaseContext(),"Exercise Deleted", Toast.LENGTH_SHORT).show();
}
}