0

I have a spinner where the contents are from an Array in Strings.xml. However I would like to be able to let the user add items to the array. Can anyone help and let me know if there is a way to do this?

Many thanks

Glenn Arnold
  • 105
  • 2
  • 8

1 Answers1

1

ArrayAdapter has a method add(object) as seen here: ArrayAdapter | Android Developer

For example:

fun addItem(item: T) {
    arrayAdapter.add(item)

    // Refreshes the view to reflect the changes applied to arrayAdapter
    arrayAdapter.notifyDataSetChanged()  
}
Iain
  • 371
  • 1
  • 3
  • 10