To find the position of "some value" in the Spinner use this: String myString = "some value"; //the value you want the position for ArrayAdapter myAdap = (ArrayAdapter) mySpinner.getAdapter(); //cast to an ArrayAdapter int spinnerPosition = myAdap.getPosition(myString); //set the default according to value mySpinner.setSelection(spinnerPosition);
Read full article from java - How to set selected item of Spinner by value, not by position? - Stack Overflow
No comments:
Post a Comment