java.lang.RuntimeException: view tag isn't correct on view:null
我的XML布局文件:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/tv_ttl_first_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="First Name:"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<TextView
android:id="@+id/tv_first_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="First Name"
android:layout_marginLeft="30dp"
android:layout_alignBaseline="@id/tv_ttl_first_name"
android:layout_toRightOf="@id/tv_ttl_first_name"
/>
</RelativeLayout>
</layout>
我有一个使用该XML的相对布局的子类:
public class ContainerSingleBabyInfo extends RelativeLayout {
private static final String TAG = ContainerSingleBabyInfo.class.getSimpleName();
protected ContainerSingleBabyInformationBinding binding;
//region Overrides
public ContainerSingleBabyInfo(Context context, AttributeSet attrs) {
super(context, attrs);
this.init(context);
}
public ContainerSingleBabyInfo(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.init(context);
}
public ContainerSingleBabyInfo(Context context) {
super(context);
this.init(context);
}
private void init(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
binding = DataBindingUtil.inflate(inflater, R.layout.container_single_baby_information, this, true);
}
}
这是我使用班级的片段:
<com.foo.bar.Views.InfoContainers.ContainerSingleBabyInfo
android:id="@+id/vw_single_baby_info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/vw_icons"
android:layout_above="@+id/vw_fresh_btn_container"
android:visibility="visible"
layout="@layout/container_single_baby_information"/>