Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find void methods in MainViewModel #2

Open
RobIsr opened this issue Jan 10, 2018 · 0 comments
Open

Cannot find void methods in MainViewModel #2

RobIsr opened this issue Jan 10, 2018 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@RobIsr
Copy link
Contributor

RobIsr commented Jan 10, 2018

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.

@RobIsr RobIsr added the help wanted Extra attention is needed label Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant