Home > Enterprise >  Android databinding with Kotlin map
Android databinding with Kotlin map

Time:06-02

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?

CodePudding user response:

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;"

  • Related