NumberPicker的格式化值在onClick时消失 [英] Formatted value of NumberPicker disappears onClick
问题描述
我的NumberPicker在setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS)
模式下并且setWrapSelectorWheel(false)
已关闭.
My NumberPicker in setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS)
mode and the setWrapSelectorWheel(false)
is turned off.
我用一个简单的格式化程序对Numberpicker进行了格式化:
I formatted my Numberpicker with a simple formatter:
mNumberPicker.setFormatter(new NumberPicker.Formatter() {
@Override
public String format(int value) {
return TextUtils.makeQuatityString(getContext(), value, R.plurals.nWeek);
}
});
示例输出:4周,其中值为4.
Example output: 4 Weeks, where 4 is the value.
NumberPicker在对话框中,然后短按该值,周"消失,"4"保持不变.现在,长按一下后,格式化的文本会重新出现.
The NumberPicker is in a Dialog and after a short click on the value, the "Weeks" disappear, the "4" stays. Now, after a longer click, the formatted text re-appears.
有人现在要解决此问题吗?
Does anybody now how to fix this?
推荐答案
Looks like this is a bug Others are facing this issue too. Check this question.
这对我有用.我在API 24上进行了测试.
This worked for me. I tested at API 24.
try {
Field f = NumberPicker.class.getDeclaredField("mInputText");
f.setAccessible(true);
EditText inputText = (EditText) f.get(yourPicker);
inputText.setFilters(new InputFilter[0]);
} catch (Exception e) {
e.printStackTrace();
}
这篇关于NumberPicker的格式化值在onClick时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!