【发布时间】:2016-03-02 06:24:01
【问题描述】:
以下代码生成一个 EditText(目标版本 23)。我已经为此工作了大约 8 个小时,并收到了一些建议,但我认为以前没有人见过这个,所以我仍然卡住了。
- 单击该字段。
- A/N 软键盘打开。
- 点击 123?左下角的按钮。数字软键盘打开。
- 按任意数字。什么都没发生。
- 长按 5,“5/8”会添加到文本字段中。
- 按任何特殊字符,例如@。它可能会添加到该字段中。
- 清除该字段。输入“for”,按 123?,现在它需要数字。
- 清除该字段。输入“for?”,按 123?,不带数字。
我添加了一个 TextWatcher。如果数字没有发布,则 TextWatcher 也看不到它们。
EditText bottomT = new EditText(model);
bottomT.setTextSize(14);
bottomT.setHint("ZIP");
bottomT.setHintTextColor(Color.BLACK);
bottomT.setBackgroundColor(Color.WHITE);
bottomT.setTextColor(Color.BLACK);
// bottomT.setInputType(InputType.TYPE_CLASS_NUMBER) Didn't make any difference.
// bottomT.setRawInputType(InputType.TYPE_CLASS_NUMBER) Didn't make any difference.
// bottomT.setText("", TextView.BufferType.EDITABLE); DIdn't make a difference
bottomT.setText("");
【问题讨论】: