I have a list objects in a Recyclerview. When long-pressing an item I want to show a dialog with data from the item clicked.
The Recyclerview
See the Variables section of the official documentation of the Data Binding Library. There you find a variable context you can use.
A special variable named context is generated for use in binding expressions as needed. The value for context is the Context from the root View's
getContext(). The context variable will be overridden by an explicit variable declaration with that name.
Basically you could just pass it to another variable like the viewModel to show the dialog from there.
android:onClick="@{v -> viewModel.showDialog(context)}"