【问题标题】:How to disable smart cast highlight Kotlin?如何禁用智能投射突出显示 Kotlin?
【发布时间】:2019-08-28 01:08:46
【问题描述】:

IDE:Android Studio 3.3

我正在 ViewHolder 上的 RecyclerView 适配器中进行 kotlin 智能转换。

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        holder as ViewHolder

现在每次提到的viewholder都被突出显示,悬停时的文字说“Smart Cast to ...”这不是问题,但真的很烦人。如何禁用此突出显示功能?

【问题讨论】:

    标签: android-studio intellij-idea kotlin


    【解决方案1】:

    转到文件 -> 设置 -> 编辑器 -> 颜色方案 -> Java/Kotlin -> 类和接口

    您应该可以在此处找到课程的配色方案。 希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      不要只使用holder as ViewHolder,而是尝试使用if (holder !is ViewHolder) throw Exception()if (holder !is ViewHolder) return

      【讨论】:

      • 这与代码无关,而是与已接受答案中的 IDE 设置有关。
      【解决方案3】:

      在 IDE 首选项中,请参阅:

      编辑器 → 配色方案 → Kotlin → 智能投射 → 智能投射值

      如果您想禁用值智能投射突出显示,只需取消选中 背景

      您可能还想配置其他类型的智能投射。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-10-08
        • 2015-03-03
        • 2022-10-16
        • 1970-01-01
        • 2014-12-17
        • 2021-06-19
        • 1970-01-01
        相关资源
        最近更新 更多