Answers for "how to set spinner value in android"

1

how to set spinner value in android

String compareValue = "some value";
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.select_state, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
if (compareValue != null) {
    int spinnerPosition = adapter.getPosition(compareValue);
    mSpinner.setSelection(spinnerPosition);
}
Posted by: Guest on October-18-2021
0

how to set current item for spinner android

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

spinnerObject.setSelection(b.get(0))
Posted by: Guest on October-02-2020

Code answers related to "how to set spinner value in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language