With the default android Number Picker, when there is only 0 and 1 inside it, the UI doesn't react properly (freeze or glitch). Is there a possibility to extends from Number Picker to have as displayed Values [0,1,0] ?Thanks!!
Asked
Active
Viewed 2,414 times
1
-
there no custom data picker which display 3 digit. – Hemant Parmar Jan 30 '18 at 09:19
-
Thanks for your response :) what would be the solution? Hm, maybe a custom viewpager? – Bénédicte Lagouge Jan 30 '18 at 09:23
2 Answers
0
I think you can do it using a compound view. I found this very helpful https://code.tutsplus.com/tutorials/creating-compound-views-on-android--cms-22889
![](../../users/profiles/5186406.webp)
eliamyro
- 311
- 1
- 4
- 19
0
You can create custom value using NumberPicker. You can use something like this:
Layout:
<android.widget.NumberPicker
android:id="@+id/custom_np"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Logic:
NumberPicker numberPicker = view.findViewById(R.id.custom_np);
...
// Define the text to be displayed in NumberPicker
String[] texts = {"0", "1"};
numberPicker.setMinValue(0);
numberPicker.setMaxValue(texts.length - 1);
numberPicker.setDisplayedValues(texts);
numberPicker.setWrapSelectorWheel(true);
![](../../users/profiles/4758255.webp)
ישו אוהב אותך
- 22,515
- 9
- 59
- 80
-
Yup, I know that. But have you tried your specific code here ? (with the array texts = {"0", "1"}) it doesn't act like if there was more numbers... – Bénédicte Lagouge Jan 30 '18 at 10:53
-
1What did you really want to achive? did you want something like this: https://stackoverflow.com/a/33053895/4758255 – ישו אוהב אותך Jan 30 '18 at 11:08