1

I have id from API and want to set a generic object having that id in the spinner. Here is my code.

fun selectValue(id: Int?) {
    for (index in 0 until spinnerType.count - 1) {
        val obj = spinnerType.getItemAtPosition(index) as DropdownMaster
        if (obj.typeDetailID == id) {
            spinnerType.setSelection(index + 1)
            return
        }
   }        
}

This worked fine before making spinner generic.

Son Truong
  • 13,661
  • 5
  • 32
  • 58
Vish
  • 11
  • 2
  • You will have to create custom ArrayAdapter of your class type. Have a look at this [link](https://dzone.com/articles/custom-spinner-for-android-application) – Ketan Ahir Jan 09 '20 at 06:54
  • another reference https://stackoverflow.com/questions/1587028/android-configure-spinner-to-use-array – Arjun Jan 09 '20 at 07:12

0 Answers0