大佬教程收集整理的这篇文章主要介绍了错误“无法使用提供的参数调用以下任何函数。:,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直致力于在 Kotlin 中学习 RecyclerVIEws,但遇到了一个我似乎无法解决的特定错误:
val itemsHashSet = HashSet(category.items)
产生错误:
不能使用提供的参数调用以下函数。
((MutableCollection
我尝试过更改格式,甚至用 Java 编写代码,然后在 AndroID studio 中将其转换都无济于事。
这是我一直坚持的课程:
class categorymanager(private val context: Context) {
fun savecategory(category: categorymodel) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val editor = sharedPreferences.edit()
val itemsHashSet = HashSet(category.items)
editor.putStringSet(category.name,itemsHashSet)
editor.apply()
}
fun retrIEveCategorIEs (): ArrayList<categorymodel> {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
val data = sharedPreferences.all
val categorIEs = ArrayList<categorymodel>()
for (item in data) {
val category = categorymodel(item.key,arraylistof(item.value.toString()))
categorIEs.add(category)
}
return categorIEs
}
}
对不起,如果我是个白痴,这很明显,但我在这里找不到一个有意义的适用答案。任何帮助表示赞赏
编辑:
类别模型:
package com.pwneill.favoriteListapp
class categorymodel (name: String,items: ArrayList<String>) {
val name = name
val items = arrayOf(items)
}
您可以像这样初始化 HashSet
:
val itemHashSet = hashSetOf(category.items)
以上是大佬教程为你收集整理的错误“无法使用提供的参数调用以下任何函数。:全部内容,希望文章能够帮你解决错误“无法使用提供的参数调用以下任何函数。:所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。