我正在使用 android studio 2.1 在 android 中使用最新的数据绑定(bind)。 使用下面代码中描述的可见性标签得到错误
java.lang.RuntimeException: Found data binding errors. / data binding error ****msg:Identifiers must have user defined types from the XML file. View is missing it file:D:\HP\HealthPortal_Android\Code\app\src\main\res\layout\cardview_image_twotextview.xml loc:68:90 - 68:93 \ data binding error
<TextView
android:id="@+id/card_sub_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/card_title"
android:layout_marginLeft="@dimen/carview_margin"
android:layout_toRightOf="@+id/card_image"
android:text="@{toolsAndTrackersCards.subtitle}"
android:textColor="@color/black"
android:textSize="20sp"
android:visibility="@{toolsAndTrackersCards.subtitle.equals(@string/Empty_String) ? View.VISIBLE : View.GONE}"
/>
做了一些谷歌而不是 abel 来找到解决方案。 @string/Empty_String 在 string.xml 文件中定义为空字符串 ""。我哪里做错了。
最佳答案
将此添加到您的 cardview_image_twotextview.xml
:
<data>
<import type="android.view.View" />
<!--your variables-->
</data>
关于android - 可见性在数据绑定(bind) android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36938504/