要は View.setOnCreateContextMenuListenerをどうするか。
一度わかってしまえばどうと言うことはなく、カスタムセッターを用意するだけ。
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="Item"
type="com.example.hoge"/>
</data>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?status_item_background_drawable"
android:onClick="@{Item.clickListener}"
app:onCreateContextMenu="@{Item.createContextMenuListener}">
</FrameLayout>
</layout>
public class BasicLogData extends BaseObservable {
@Bindable
public View.OnCreateContextMenuListener getCreateContextMenuListener() {
return XXX;
}
@BindingAdapter("app:onCreateContextMenu")
public static void setOnCreateContextMenu(View view, View.OnCreateContextMenuListener listener) {
view.setOnCreateContextMenuListener(listener);
}
}