Forum

android, kotlin, Ar...
 
Notifications
Clear all

android, kotlin, ArrayAdapter example

1 Posty
1 Users
0 Reactions
1,422 Widok
0
Topic starter

list

1 Answer
0
Topic starter
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        var array = arrayOf("Melbourne", "Vienna", "Vancouver", "Toronto", "Calgary", "Adelaide", "Perth", "Auckland", "Helsinki", "Hamburg", "Munich", "New York", "Sydney", "Paris", "Cape Town", "Barcelona", "London", "Bangkok")

        val myAdapter = ArrayAdapter(context!!, android.R.layout.simple_list_item_single_choice, array)
        lista.adapter = myAdapter
        lista.onItemClickListener = AdapterView.OnItemClickListener { _, view, _, _ ->
            view.isSelected = true
        }
    }

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: