小编jga*_*oid的帖子

使用Android中的EditText格式化货币字符串

我正在尝试格式化Android中EditText的输入值,我想用货币值格式化输入,我尝试了以下内容:

EditText minimo = (EditText) view.findViewById(R.id.minimo);

Locale locale = new Locale("en", "UK");
NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);

 Locale locale = new Locale("en", "UK");
    NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);

    minimo.setText("", TextView.BufferType.valueOf(String.valueOf(fmt.format(TextView.BufferType.EDITABLE))));
Run Code Online (Sandbox Code Playgroud)

日志:

java.lang.IllegalArgumentException: Bad class: class android.widget.TextView$BufferType
Run Code Online (Sandbox Code Playgroud)

java string formatting android android-edittext

2
推荐指数
1
解决办法
2467
查看次数

标签 统计

android ×1

android-edittext ×1

formatting ×1

java ×1

string ×1