“Not enough information to infer parameter T” with Kotlin and Android

后端 未结 5 1936
遥遥无期
遥遥无期 2020-12-13 05:17

I\'m trying to replicate the following ListView in my Android app using Kotlin: https://github.com/bidrohi/KotlinListView.

Unfortunately I\'m getting an error I\'m u

5条回答
  •  旧时难觅i
    2020-12-13 05:44

    Andoid O change findViewById api from

    public View findViewById(int id);

    to

    public final T findViewById(int id)

    so, if you are target to API 26, you can change

    val listView = findViewById(R.id.list) as ListView

    to

    val listView = findViewById(R.id.list)

    or

    val listView: ListView = findViewById(R.id.list)

提交回复
热议问题