【问题标题】:Querying Androids ContactsContract in Kotlin在 Kotlin 中查询 Androids ContactsContract
【发布时间】:2015-01-07 22:11:16
【问题描述】:

我在使用 Kotlin 编写的 Android 应用程序中查询 ContactsContract 时遇到了一些麻烦。 Android Studio 会从未解决的引用中给出错误,例如来自 ContactsContract.Contacts._ID。有谁知道在 Kotlin 中查询这些的正确方法?

【问题讨论】:

  • 这已在 Kotlin 1.0 Beta 1 中修复,问题 KT-3180

标签: android kotlin


【解决方案1】:

这是 Kotlin 中的一个开放错误。请参考:https://youtrack.jetbrains.com/issue/KT-3180

现在您可以使用 Java 访问这些字段作为一种解决方法:

public class ContactsSupport {
    public static interface BaseColumns {
        public static final String _ID = ContactsContract.RawContacts._ID;
        public static final String _COUNT = ContactsContract.RawContacts._COUNT;
    }
}

所以你可以在 Kotlin 中写 ContactsSupport.BaseColumns._ID

【讨论】:

  • 这已在 Kotlin 1.0 Beta 1 中修复,问题 KT-3180
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-05-27
  • 1970-01-01
  • 2021-08-24
  • 2021-07-17
  • 1970-01-01
  • 1970-01-01
  • 2020-08-28
相关资源
最近更新 更多