Code example for NumberPicker

Methods: clearFocushasFocussetEnabledsetMaxValuesetMinValue, setFocusable, setFocusableInTouchMode, setOnFocusChangeListener

0
        if (!enabled) {
            if (nameEdit.hasFocus()) {
                nameEdit.clearFocus();
            } else if (univEdit.hasFocus()) {
                univEdit.clearFocus();
            } else if (addrEdit.hasFocus()) {
                addrEdit.clearFocus();
            } 
        } 
 
        nameEdit.setFocusable(enabled);
        nameEdit.setFocusableInTouchMode(enabled);
        univEdit.setFocusable(enabled);
        univEdit.setFocusableInTouchMode(enabled);
        univEdit.setEnabled(enabled);
        addrEdit.setFocusable(enabled);
        addrEdit.setFocusableInTouchMode(enabled);
        addrEdit.setEnabled(enabled);
        colorPicker.setEnabled(enabled);
        svBar.setEnabled(enabled);
 
    } 
 
    @Override 
    public void onFocusChange(View view, boolean hasFocus) {
        showHideKeyboard(view, hasFocus);
    } 
 
    @Override 
    public void onViewCreated(View view, Bundle savedInstanceState) {
        nameEdit = (EditText)view.findViewById(R.id.light_detail_name_edit);
        univEdit = (NumberPicker)view.findViewById(R.id.light_detail_universe_picker);
        addrEdit = (NumberPicker)view.findViewById(R.id.light_detail_addr_picker);
        colorPicker = (ColorPicker)view.findViewById(R.id.light_detail_color_picker);
        svBar = (SVBar)view.findViewById(R.id.light_detail_color_svbar);
 
        nameEdit.setOnFocusChangeListener(this);
        univEdit.setOnFocusChangeListener(this);
        univEdit.setMinValue(0);
        univEdit.setMaxValue(2);
        addrEdit.setOnFocusChangeListener(this);
        addrEdit.setMinValue(1);
        addrEdit.setMaxValue(512);
 
        colorPicker.addSVBar(svBar);
        colorPicker.setOnColorChangedListener(this);
 
        setControlsEnabled(false);