【发布时间】:2015-02-05 06:27:25
【问题描述】:
加载数字选择器时,默认值不会出现在屏幕上,直到被触摸。
一旦触摸,一切正常。任何帮助表示赞赏。
此外,如果格式化程序被删除,它也可以正常工作。
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" />
这是活动代码:
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);
提前致谢
【问题讨论】:
-
会不会是最初的文字颜色和背景颜色匹配?如果没有设备,很难想象您所看到的。
标签: android numberpicker