Code example for Spinner

Methods: getAdapter, setSelection

0
    /** Set the state of the spinner. 
     *   
     *  @param value The value of the choice selected. 
     */ 
    public void setValue(String value) {
        int position = ((ArrayAdapter<String>) _spinner.getAdapter())
                .getPosition(_valuesToChoices.get(value));
        if (position >= 0) {
            _spinner.setSelection(position);
        } 
    } 
 
    /** Get the value represented by the spinner based on its position. 
     *  
     *  @param position The position of the selected item. 
     *  @return The value represented by the given position. 
     */ 
    public String getValue(int position) {
        return _choicesToValues.get(_spinner.getItemAtPosition(position));
    }