EditText field in Android to corectly format -
as title asks, want correctly monitor edit text field format entered numbers currency "." being l=placed or inserted after last 3 digits of cell.
in user inputs numbers , field expands edittext reflect numbers entered reflect currency, example below:
user enters "123456789"
the edittext reflect : "123.456.789"
any suggestions or comments welcome.
try this
edittext variablename = .... variablename.addtextchangedlistener(new textwatcher() { @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void ontextchanged(charsequence s, int start, int before, int count) { } @override public void aftertextchanged(editable s) { if(3 == s.length() % 4){ s.append('.'); // change fire event again, careful, avoid infinite loops } } });
Comments
Post a Comment