我有一个edittext,它只获得没有十进制数字的数字.
android:inputType="number"
Run Code Online (Sandbox Code Playgroud)
我打算在打字的时候把数千人分开.例如25,000.
我知道我应该使用TextWatcher并且我已经使用过这段代码,但是我无法使用它:
@Override
public void afterTextChanged(Editable viewss) {
String s = null;
try {
// The comma in the format specifier does the trick
s = String.format("%,d", Long.parseLong(viewss.toString()));
} catch (NumberFormatException e) {
}
}
Run Code Online (Sandbox Code Playgroud)
你能帮我这么做吗?