Code example for NumberPicker

Methods: setOnValueChangedListener

0
    
    // Listen for changes to each 'picker', if changes are detected, update the global color, 
    // then the background using RGB. 
    private void pickerListener(NumberPicker picker, final String colorType) {
       
      picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
 
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {	
          updateColor(colorType, newVal);
          updateBackground(); 
        } 
      }); 
    } 
 
    // Update the global color variable, which color is updated is based on the 'colorType'  
    // which is a flag determined by the original picker listener type. 
    private void updateColor(String colorType, int color) {
      if (colorType == "r")
        red = color;
      if (colorType == "g")
Stop searching for code, let great code find you!  Add Codota to your java IDE