-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
In todo_item.xml I am setting the "onClick" attribute to the LinearLayout which, in turn, contains the cardview with the note. As below I am using the removeNote() method from MainViewModel and passing in the position variable like below:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:orientation="vertical"
**android:onClick="@{() -> viewModel.removeNote(position)}">**
When I try to make the removeNote function a void function I cannot find it from the xml. The only solution that worked for me was to make it return something. So even if it doesnt need to I made return a boolean just to find it:
//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;
}
I am trying to figure out why this is, and if there is a way to call void functions and still pass them parameters.
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed