Ok this should be a fun one...
We have a Fragment with a viewmodel: RoomFragment.java, fragment_room.xml, and RoomViewModel.java The Fragment's view is binded to the xml, and the viewModel is available in that xml.
So far so good.
Now...I'm creating a new custom view object: CustomView.kt ...and I want to use this custom view within a parent view (fragment_room.xml) AND be able to bind buttons in my CustomView to methods in the parent's viewModel.
For some pseudocode... (fragment_room.xml)
<ParentView>
<data>
<variable viewModel>
</data>
<Button
android:onClick:"@{viewModel::onSomeButtonClick}"
/>
<com.my.CustomView
android:width
android:height
app:myCustomAction:@{viewModel::onClickCustomButton}"
/>
</ParentView>
(This is currently set to a string...but changing it doesn't change anything.)
<declare-styleable name="CustomView">
<attr name="app:myCustomAction" format="string"/>
</declare-styleable>
The error
app:myCustomAction:@{viewModel::onClickCustomButton}"
gives me
Could not resolve viewModel::onClickCustomButton as a listener.
Any ideas? Or if there's a better way...?