【发布时间】:2016-04-05 06:41:03
【问题描述】:
我在 Edittext 的 addTextChangedListener 方法中有自定义 DecimalFormat,一切正常,但是当我更改语言(区域设置)时,我的 addTextChangedListener 不起作用。
double answer = inputDouble * counterToDouble;
DecimalFormat df = new DecimalFormat("##.########");
// df=(DecimalFormat)numberFormat;
df.setRoundingMode(RoundingMode.DOWN);
answer = Double.parseDouble(df.format(answer));
unicoinsAmmount.setText(String.valueOf(df.format(answer)));
我搜索了一下我的问题,找到了NumberFormat解决方案:
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
但我不知道如何使用此代码。
【问题讨论】:
-
试试 DecimalFormat df = DecimalFormat.getInstance(Locale.US);
-
谢谢,但我如何使用这种模式的语言环境##.########? @Viren
-
尝试 DecimalFormat 格式化程序 = DecimalFormat.getInstance(Locale.US); formater.applyPattern("#.##");
标签: java android bigdecimal decimalformat