etwa wie folgt:Können wir Root-Ansicht in einem XML-Layout in Databinding abrufen?
android:onClick="@{() -> presenter.onClick(rootView)}"
Quellcode:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="presenter"
type="Presenter" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{() -> presenter.onClick(rootView)}"
android:text="abcde" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="tytyt" />
</LinearLayout>
</layout>
Was Sie von 'rootView' bedeuten sie? Sie können das Ansichtsobjekt des Layouts mit 'binding.getRoot()' aufrufen. Lass es mich wissen, wenn du nicht danach suchst. –
Ich möchte es von xml, nicht von Code – Sam