0

I made a spinner with a drop-down menu and wanted to make a multiple-choice list. I used the following command but only one item is selected. I am new to this and am working on a uni project.

val dropdown = findViewById<Spinner>(R.id.selectRepeat)

val selectDays =
    arrayOf(
        "Only Once",
        "Everyday",
        "Monday",
        "Tuesday",
        "Wednesday",
        "Thursday",
        "Friday",
        "Saturday",
        "Sunday"
    ) // Creating an array list

// set array in adapter
val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, selectDays)

dropdown.adapter = adapter

dropdown.onItemSelectedListener =
    object : AdapterView.OnItemSelectedListener {
        override fun onNothingSelected(p0: AdapterView<*>?) {
            TODO("Not yet implemented")
        }

        override fun onItemSelected(p0: AdapterView<*>?, p1: View?, p2: Int, p3: Long) {
            Toast.makeText(this@SetAlarm, "You have Selected " + selectDays[p2], Toast.LENGTH_LONG)
                .show()
        }
    }
Demigod
  • 5,073
  • 3
  • 31
  • 49

0 Answers0