您需要将
data定义放在您的之外
LinearLayout:
<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <!-- data setup --> <data> <variable name="location" type="com.myapp.models.Address" /> </data> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.myapp.views.fragments.LocationSearchFragment"> </LinearLayout></layout>



