This code works fine:
Adapter Code:
@BindingAdapter({"app:onClick"})
public static void setOnClick(My view, View.OnClickListener onClickListener)
{
view.addOnClickListener(onClickListener);
}
Xml code:
app:onClick="@{ (v) -> view.onClick(v) }"
But I need to make a custom listener as follows:
Adapter Code:
@BindingAdapter({"app:onClose"})
public static void setOnClose(My view, My.OnCloseListener onCloseListener)
{
view.addOnCloseListener(onCloseListener);
}
Xml code:
app:onClose="@{ (x, y) -> view.onClose(x, y) }"
Listener Code:
public interface OnCloseListener
{
void onClose(My x, int y);
}
In this case, the application does not compile (not a big surprise :(), is it possible to use lambda with a custom listener?
source
share