使用String.format()
public static String afterTextChanged(String view) {
String s = null;
try {
s = String.format("%,d", Long.parseLong(view));
} catch (NumberFormatException e) {
return view;
}
return s;
}
结果
123
1,234
12,345
12,345,678