val b: List<Int> = a.mapIndexed { i, b -> if (b) i else null }.filterNotNull().toList() spinnerObject.setSelection(b.get(0))