Solution 1 :
I guess it is not possible to add a picture with the normal spinner , if you want to add an image to spinner , you will need to make a custom class “Custom Spinner”
Problem :
how can I add images to each item of my spinner.
My code:
val lista = arrayOf("Kotlin","Python","Java","Mongodb","GoLand","C++")
val adaptador = ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,lista)
spinner.adapter = adaptador
when(spinner.selectedItem.toString()){
"Koltin" -> Toast.makeText(this,"Kotiin",Toast.LENGTH_SHORT).show()
"Python" -> Toast.makeText(this,"Python",Toast.LENGTH_SHORT).show()
"Java" -> Toast.makeText(this,"Java",Toast.LENGTH_SHORT).show()
"Mongodb" -> Toast.makeText(this,"Mongodb",Toast.LENGTH_SHORT).show()
"GoLand" -> Toast.makeText(this,"GoLand",Toast.LENGTH_SHORT).show()
"C++" -> Toast.makeText(this,"C++",Toast.LENGTH_SHORT).show()
}
Comments
Comment posted by Jorge Leonardo
How do I do it in koltin?
Comment posted by dzone.com/articles/custom-spinner-for-android-application
I solved my question with this tutorial.l: