类似以下内容:我们可以在Databinding的xml布局中获得Root View吗?
android:onClick="@{() -> presenter.onClick(rootView)}"
的源代码:
<?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>
你所说的'rootView'意思?您可以使用'binding.getRoot()'获得布局的视图对象。让我知道你是不是在寻找这个。 –
我想从xml中得到它,而不是从代码 – Sam