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
You seem no change in listview because your ArrayList or Array you assigned to the adapter has no changes. Please remove the item from the ArrayList or array too. And you just have to call notifyDataSetChanged() ., ie, there is no need of calling listview.setAdapter(adapter) again.
EDIT :
please replace your customArrayAdapter with the below shown code
private ArrayList workouts;
public CustomExerciseAdapter(Context context, ArrayList workouts) {
super(context, R.layout.exercise_custom_row, workouts);
this.workouts = workouts;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View customView = inflater.inflate(R.layout.exercise_custom_row, parent, false);
/////here change to
String singleExerciseItem = (String)workouts.get(position);
TextView exerciseTV = (TextView) customView.findViewById(R.id.exerciseTV);
exerciseTV.setText(singleExerciseItem);
return customView;
}
public void setList(ArrayList workouts){
this.workouts = workouts;
notifyDatasetChanged();
}
}
In your delete method, after updating database and your list, call adapter.setList(workouts),. it may do the trick for you.