[英]Cannot refer to other View ID in Android data binding
I just finished watching Advanced Data Binding - Google I/O 2016 and would like to apply the following to reduce repetition of my expression used in different views. 我刚刚观看了高级数据绑定 - Google I / O 2016,并希望应用以下内容来减少在不同视图中使用的表达式的重复。
But I cannot make it work in my case: 但我不能让它在我的情况下工作:
<ImageButton
android:id="@+id/btn_list"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="start"
android:background="@drawable/btn_s01_list"
android:visibility="@{bean.shouldHideControls? View.GONE: View.VISIBLE}"/>
<ToggleButton
android:id="@+id/btn_radar"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/btn_radar_selector"
android:checked="false"
android:gravity="end"
android:text=""
android:textOff=""
android:textOn=""
android:visibility="@{btn_list.visibility}"/>
and I got 我得到了
Error:(426, 39) Identifiers must have user defined types from the XML file.
错误:(426,39)标识符必须具有XML文件中的用户定义类型。 btn_list is missing it
btn_list缺少它
Edit: 编辑:
I missed an important point in the same talk... The View IDs are camel-casified. 我在同一个谈话中错过了一个重要的观点...视图ID是骆驼式的。
The binding process converts your IDs to properties in the binding class, and the generated names are camel-casified. 绑定过程将您的ID转换为绑定类中的属性,并且生成的名称是camel-casified。
You may need to change the following line: 您可能需要更改以下行:
android:visibility="@{btn_list.visibility}"/>
To this: 对此:
android:visibility="@{btnList.visibility}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.