@Override public void onValueChange(NumberPickerView picker, int oldVal, int newVal) { String[] content = picker.getDisplayedValues(); if (content != null) { Log.d(TAG,"onValueChange content : " + content[newVal - picker.getMinValue()]); Toast.makeText(mContext.getApplicationContext(), "oldVal : " + oldVal + " newVal : " + newVal + "\n" + mContext.getString(R.string.picked_content_is) + content[newVal - picker.getMinValue()], Toast.LENGTH_SHORT) .show(); } }
private void getCurrentContent(){ String[] content = mNumberPickerView.getDisplayedValues(); if (content != null) Toast.makeText(mContext.getApplicationContext(), mContext.getString(R.string.picked_content_is) + content[mNumberPickerView.getValue() - mNumberPickerView.getMinValue()], Toast.LENGTH_SHORT) .show(); } }
@Override public void onValueChange(NumberPickerView picker, int oldVal, int newVal) { String[] content = picker.getDisplayedValues(); if (content != null) Toast.makeText(getApplicationContext(),"oldVal : " + oldVal + " newVal : " + newVal + "\n" + getString(R.string.picked_content_is) + content[newVal - picker.getMinValue()], Toast.LENGTH_SHORT) .show(); }
private void getCurrentContent(){ String[] content = picker.getDisplayedValues(); if (content != null) Toast.makeText(getApplicationContext(), getString(R.string.picked_content_is) + content[picker.getValue() - picker.getMinValue()], Toast.LENGTH_SHORT) .show(); }
/** * simplify the "setDisplayedValue() + setMinValue() + setMaxValue()" process, * default minValue is 0, and make sure you do NOT change the minValue. * @param display new values to be displayed */ public void refreshByNewDisplayedValues(String[] display) { int minValue = getMinValue(); int oldMaxValue = getMaxValue(); int oldSpan = oldMaxValue - minValue + 1; int newMaxValue = display.length - 1; int newSpan = newMaxValue - minValue + 1; if (newSpan > oldSpan) { setDisplayedValues(display); setMaxValue(newMaxValue); } else { setMaxValue(newMaxValue); setDisplayedValues(display); } }
int oldStart = pickerView.getMinValue(); int oldStop = pickerView.getMaxValue(); int oldSpan = oldStop - oldStart + 1;