java - Fast tapping on soft keyboard -


i'm using textwatcher prevent users insert double spaces. following part of code.

        @override         public void aftertextchanged(editable s) {          final string = s.tostring();             final string b = s.tostring().replace("  ", " ");               if (a.length()>b.length()){                 int pos = name.getselectionstart();                 name.settext(b);                 name.setselection(pos-1);             }}       

the code works fine if 1 simple taps slowly. anyway, problems arise when tap quite fast, begins deleting characters before first space.

do have idea why happen , how solve it?


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -