0

So i have a class

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) } } } 

The problem is that i can't modify invited, it says unresolved reference

I have tried to change invited.add(mUsers.get(position).idUser) for:

this.invited... createLobby.invited... ((createLobby) stuff here) 

but it hasn't work, any ideas or help? Thanks!

1 Answer 1

3

It looks like you want to mark your inner class with inner. See here: https://kotlinlang.org/docs/reference/nested-classes.html

So you would have:

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) } } } 
Sign up to request clarification or add additional context in comments.

1 Comment

omg i read that and i forgot to write the inner, give me a min and let me try it, thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.