You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to notify the ToDoAdapter in Main Activity using notifyDataSetChanged() i get no response. My solution so for is to set a new ToDoAdapter on the RecyclerView. The problem is in these two methods:
In MainViewModel:
//This function removes a note from the database and sets a new Adapter with the updated list of notes.
public boolean removeNote(long id) {
//Call mDb.delete to pass in the TABLE_NAME and the condition that WaitlistEntry._ID equals id
mDb.delete(ToDoContract.TodoEntry.TABLE_NAME, ToDoContract.TodoEntry._ID + "=" +
String.valueOf(id), null);
MainActivity.mTodoRecyclerView.setAdapter(new ToDoAdapter(allNotes(), this));
Log.d(TAG, "removeNote: " + "clicked");
return true;
}
and in MainActivity:
/* This function stores the entered text inside the noteEndered String and calls the addNote function in
MainViewModel to get the new list of notes from the allNotesCursor and sets a new Adapter to the
RecyclerView
*/
public void addNoteFromEditText(View view) {
String noteEntered = binding.enterNoteEditText.getText().toString();
viewModel.addNote(noteEntered);
binding.enterNoteEditText.setText("");
mTodoRecyclerView.setAdapter(new ToDoAdapter(viewModel.allNotes(), viewModel));
}
If anyone has an idea about any better way of doing this then I would appreciate the help.
The text was updated successfully, but these errors were encountered:
When trying to notify the ToDoAdapter in Main Activity using notifyDataSetChanged() i get no response. My solution so for is to set a new ToDoAdapter on the RecyclerView. The problem is in these two methods:
In MainViewModel:
and in MainActivity:
If anyone has an idea about any better way of doing this then I would appreciate the help.
The text was updated successfully, but these errors were encountered: