Java Code Examples for android.widget.NumberPicker#setFormatter()
The following examples show how to use
android.widget.NumberPicker#setFormatter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * Customizes the options shown in the {@link NumberPicker}s to represent i with the string * i - 1 and 0 with a blank option * * @param id */ private void prepareNumberPicker(int id) { NumberPicker np = (NumberPicker) findViewById(id); np.setMinValue(0); np.setMaxValue(1001); np.setWrapSelectorWheel(false); np.setFormatter(new NumberPicker.Formatter() { @Override public String format(int i) { if (i == 0) return " "; return String.valueOf(i - 1); } }); }
Example 2
Source File: TestActivity.java From medical-data-android with GNU General Public License v3.0 | 5 votes |
/** * Customizes the options shown in the {@link NumberPicker}s to represent i with the string * (i - 1) * 10 and 0 with a blank option. That means that the step for the caffeine is 10 * instead of 1 * * @param id */ private void prepareCaffeineNumberPicker(int id) { NumberPicker np = (NumberPicker) findViewById(id); np.setMinValue(0); np.setMaxValue(10010); np.setWrapSelectorWheel(false); np.setFormatter(new NumberPicker.Formatter() { @Override public String format(int i) { if (i == 0) return " "; return String.valueOf((i - 1) * 10); } }); }