简体   繁体   中英

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. How the heck do I import the Map object in the xml? 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.

I create formIds as follows:

val _formIds =
        mapOf<FormType, Map<String, Int>>(...

Anyone know?

type="kotlin.collections.MapsKt" is not enought for databinding. Declare it explictly with types and provide import if required. For example type="java.util.HashMap&lt;String, Integer&gt;"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM