Android绑定“类型”与元素类型“变量”相关联的元素被关联。不得包含“<”字符 [英] Android-Binding "type" associated with an element type "variable" must not contain the '<' character
本文介绍了Android绑定“类型”与元素类型“变量”相关联的元素被关联。不得包含“<”字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误:与元素类型变量关联的属性类型的值不能包含<字符。
在xml中type = ObservableField />被涂成红色。
And type="ObservableField"/> is colored red in xml.
有什么想法吗?
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<import type="android.databinding.ObservableField"/>
<variable name="field" type="ObservableField<String>"/>
</data>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="72dp"
android:text="@{field.get()}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="181dp"
android:layout_marginEnd="149dp"
android:layout_marginStart="147dp"
android:layout_marginTop="191dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
</layout>
推荐答案
有点晚了,但是你可以这样做将< 和> 替换为& lt;
和&<
A little late, but you can do it this by replacing the < and > for <
and >
, respectively.
就像这样:<变量名= field type = ObservableField& lt; String& gt; />
这篇关于Android绑定“类型”与元素类型“变量”相关联的元素被关联。不得包含“<”字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文