[英]Android databinding with Kotlin map
This is a basic question that for some reason Google doesn't seem to have the answer.这是一个基本问题,出于某种原因,谷歌似乎没有答案。 I'm trying to use a Kotlin map object with databinding for xml.
我正在尝试将 Kotlin 地图对象与 xml 数据绑定一起使用。 How the heck do I import the Map object in the xml?
如何在 xml 中导入 Map 对象? Using
使用
name="formIds"
type="kotlin.collections.MapsKt" />
doesn't import the map object.不导入地图对象。 I get a
Failed to resolve Bracked Expr formIds["Submit"], target: kotlin.collections.MapsKt
when I try to use the object.当我尝试使用该对象时,我得到一个
Failed to resolve Bracked Expr formIds["Submit"], target: kotlin.collections.MapsKt
。
I create formIds as follows:我创建 formIds 如下:
val _formIds =
mapOf<FormType, Map<String, Int>>(...
Anyone know?有人知道吗?
type="kotlin.collections.MapsKt"
is not enought for databinding. type="kotlin.collections.MapsKt"
不足以进行数据绑定。 Declare it explictly with types and provide import if required.用类型明确声明它并在需要时提供导入。 For example
type="java.util.HashMap<String, Integer>"
例如
type="java.util.HashMap<String, Integer>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.