I'd like to define an event listener in the XML that finishes the enclosing activity, like this:
<EditText
android:id="@+id/finish"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
android:inputType="text"
android:onEditorAction="@{() -> activity.finish()}" />
However, I don't have a reference to the enclosing activity. I know I can pass it using a <variable>
, but Activity
seems a too common variable to be explicitly passed in every layout... I thought data-binding was introduced to simplify code. I didn't find any hint in the ViewDataBinding class.