在我的应用程序中我有一个自定义文本框BasicEditField.FILTER_NUMERIC
。当用户在字段中输入值时,应将逗号添加到货币格式。黑莓文本字段中的逗号分隔
EX:1,234,567,8 ....像这样。
在我的代码我试过这样。
protected boolean keyUp(int keycode, int time) {
String entireText = getText();
if (!entireText.equals(new String(""))) {
double val = Double.parseDouble(entireText);
String txt = Utile.formatNumber(val, 3, ",");// this will give the //comma separation format
setText(txt);// set the value in the text box
}
return super.keyUp(keycode, time);
}
它会给出正确的数字格式。当我在文本框中它会通过IllegalArgumentException
设置的值。我知道BasicEditField.FILTER_NUMERIC
将不会允许像逗号(...)的charector ..
我该如何做到这一点?
你需要让自己的滤波扩展TextFielter,HTTP://www.blackberry。 COM /开发者/文档/ 6.0.0api /净/轮辋/设备/ API/UI /文本/ TextFilter.html。之后需要将该过滤器设置为BasicEditField实例。 – Rupak 2012-07-30 10:23:06
BasicEditField.FILTER_NUMERIC已连接到BlackBerry的语言环境。一些区域设置使用不同的方法进行时段分隔。 – 2012-07-30 10:34:20