【问题标题】:kotlin gives me an infer type error when using findViewByIdkotlin 在使用 findViewById 时给了我一个推断类型错误
【发布时间】:2021-06-28 13:24:26
【问题描述】:

我的 android 工作室有问题。 我正在上课,所以我需要修复。

我用这条线:

val tvRslt: TextView by lazy { findViewById(R.id.tvRslt) }

它给出了这个错误: 类型推断失败:没有足够的信息来推断参数 T in

当我添加这样的类型时,错误消失了: 在 findViewById 这样之后:

val tvRslt: TextView by lazy { findViewById<TextView>(R.id.tvRslt) }

但我需要知道如何修复它,使其像这里的第一个代码一样工作,因为我的代码会给我的课程导师带来错误..

谢谢:)

【问题讨论】:

标签: android kotlin


【解决方案1】:

其实更新 kotlin 版本解决了这个问题

【讨论】:

    猜你喜欢
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多