Code example for Spinner

Methods: setAdapter, getAdapter, getContext, setOnItemSelectedListener

0
     *          the system view perspective. 
     */ 
    public <T> void setUpSpinner(@Nonnull Spinner spinner, @Nonnull String[] userValues,
                                 @Nonnull T[] systemValues, @Nonnull SpinnerItemSelectedListener<T> listener){
        OnItemSelectedListener mappingListener = new SpinnerUserToSystemViewMapper<T>(systemValues, listener);
        spinner.setOnItemSelectedListener(mappingListener);
        spinner.setAdapter(new ArrayAdapter<String>(spinner.getContext(), android.R.layout.simple_spinner_item,
                userValues));
        // NB: this check will deliberately fail at runtime and should be picked up 
        // during development/testing You could remove this and use assert() 
        // (assuming you enable them) if you don't wish to have this check applied 
        // in released clients. 
        checkArgument(spinner.getAdapter().getCount() == systemValues.length, "System values len: "
                + systemValues.length + " don't match user values: " + userValues.length);
    } 
 
    /** 
     * Android {@link OnItemSelectedListener} which maps the User view to the 
     * System view using the position in the equally sized arrays. 
     * 
     * @param <T>