所以我有一个班级
class createLobby : AppCompatActivity() {
var invited = ArrayList<String>()
private class myCustomAdapter(context: Context, users:ArrayList<User>): BaseAdapter() {
override fun getView(position: Int, convertView: View?, viewGroup: ViewGroup?): View {
invited.add(mUsers.get(position).idUser)
}
}
}
问题在于我无法修改被邀请,它表示未解决的参考
我尝试更改invited.add(mUsers.get(position).idUser)
:
this.invited...
createLobby.invited...
((createLobby) stuff here)
但它没有工作,任何想法或帮助? 谢谢!
答案 0 :(得分:3)
看起来你想用inner
来标记你的内部类。见这里:https://kotlinlang.org/docs/reference/nested-classes.html
所以你会:
class createLobby : AppCompatActivity() {
var invited = ArrayList<String>()
private inner class myCustomAdapter(context: Context, users:ArrayList<User>): BaseAdapter() {
override fun getView(position: Int, convertView: View?, viewGroup: ViewGroup?): View {
invited.add(mUsers.get(position).idUser)
}
}
}