I've an edittext
, it only gets numeric without decimal numbers.
android:inputType="number"
I want to separate thousands while I'm typing . For example 25,000 .
I know I should use TextWatcher
and I've used this code but I couldn't make it work :
@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) {
}
}
Could you help me to do so ?