Code example for Spinner

Methods: getContextgetAdaptersetAdapter, setOnItemSelectedListener

     *          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.setAdapter(new ArrayAdapter<String>(spinner.getContext(), android.R.layout.simple_spinner_item,
        // 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.