[英]Cannot refer child view on <include> through android data binding
我是 android 數據綁定的新手。 我無法參考的子視圖
不能做binding.inHeader.tvTryAgain
當嘗試訪問inHeader
子視圖時,我無法通過Android data binding
獲得任何生成 id 的建議
主文件
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@drawable/im_bg_sign_up">
<include
android:id="@+id/in_header"
layout="@layout/header_title_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</include>
</RelativeLayout>
</layout>
header_title_activity.xml
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:id="@+id/li_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/re_error_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/re_title"
android:animateLayoutChanges="true"
android:background="@color/grey_normal"
android:visibility="gone">
<com.bigstar.tv.view.TextviewNormal
android:id="@+id/tv_error_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="@+id/tv_try_again"
android:padding="5dp"
android:text="Please fill in all the details to continue signing up"
android:textColor="@color/white"
android:textSize="@dimen/text_small"
android:textStyle="normal"
android:typeface="normal" />
<com.bigstar.tv.view.TextviewNormal
android:id="@+id/tv_try_again"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:gravity="center"
android:padding="10dp"
android:text="@string/retry"
android:textColor="@color/cyan1"
android:textSize="@dimen/text_small"
android:textStyle="normal"
android:typeface="normal"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
</layout>
如果我正確理解了您的問題,我想您想在main.xml的include標記中添加“ include.xml”。 為此,將您的包含部分修改為:
<include
android:id="@+id/in_header"
layout="@layout/include"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</include>
去掉 id 標簽中的下划線並嘗試清理
android:id="@+id/inHeader"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.