我怎样才能格式化字符串数量在安卓编辑字段逗号 [英] How can I format a String number to have commas in android Edit Field
本文介绍了我怎样才能格式化字符串数量在安卓编辑字段逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关什么功能,我可以在Android中使用,以显示该号码为不同的格式。
For what function I can use in android to display the number into different formats.
有关,例如: 如果我输入1000,然后它应该显示像这样1000。 如果我输入10000,然后它应该显示这样的10,000。 如果我输入100000那么它应该显示像这样1,000,000。
For eg: If I enter 1000 then it should display like this 1,000. If I enter 10000 then it should display like this 10,000. If I enter 100000 then it should display like this 1,000,000.
请指引我。
推荐答案
您应该使用的DecimalFormat
,只是格式化数字
You should use DecimalFormat
and just format the number
DecimalFormat formatter = new DecimalFormat("#,###,###");
String yourFormattedString = formatter.format(100000);
其结果将是
-
1,000,000
达到1000000 -
10,000
10000 -
1000
1000
1,000,000
for 100000010,000
for 100001,000
for 1000
等
这篇关于我怎样才能格式化字符串数量在安卓编辑字段逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文