0

I have this spinner to and i want to get the selected item to a string and i do this:

Spinner to;
String string = to.getSelectedItem().toString;

My question is how to convert "string" back to spinner widget?

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186

1 Answers1

0

This is better:

How to set selected item of Spinner by value, not by position?

This will also work: (my answer) You create a Spinner with an Array(List). If you want to set the Spinner to the string you got from the Spinner itself, something like this would work:

for (int i = 0; i < array.size(); i++) {
    if (array.get(i).equals(string) {
        spinner.setSelection(i)
    }
}
Community
  • 1
  • 1