Ren*_*ith 6 android numberpicker
加载数字选择器后,触摸前默认值不会出现在屏幕上.
一旦感动,一切正常.任何帮助赞赏.
此外,如果格式化程序被删除,它工作正常.

dialog.xml
<NumberPicker
android:id="@+id/number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/apply_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/number_picker"
android:text="@string/ok_string" />
Run Code Online (Sandbox Code Playgroud)
这是活动代码:
final NumberPicker np = (NumberPicker) d.findViewById(R.id.number_picker);
np.setMaxValue(50);
np.setMinValue(0);
np.setWrapSelectorWheel(true);
np.setOnValueChangedListener(this);
np.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
np.setFormatter(new NumberPicker.Formatter() {
@Override
public String format(int i) {
if (i == 25)
return "0";
else
return String.valueOf(i - 25);
}
});
np.setValue(25);
Run Code Online (Sandbox Code Playgroud)
提前致谢
@Renjith
感谢您的链接,但我认为您应该链接代码,甚至将其粘贴到此处。 https://code.google.com/p/android/issues/detail?id=35482#c9
Field f = NumberPicker.class.getDeclaredField("mInputText");
f.setAccessible(true);
EditText inputText = f.get(mPicker);
inputText.setFilters(new InputFilter[0]);
Run Code Online (Sandbox Code Playgroud)