android - onTextChanged prevet space / new line -


i trying , not work: trying prevent space key writing edittext , not prevent that, i`m trying code:

@override public void ontextchanged(charsequence s, int start, int before, int count) {     if((addresstextbox.gettext().tostring().contains(" "))) {         return;     } } 

how can prevent new line (ascii char number 10) ?

for new line add android:singleline="true" "edittext" in xml file

for blank space use (as said @aksiddique in answer)

@override public void aftertextchanged(editable s) {     string result = s.tostring().replaceall(" ", "");     if (!s.tostring().equals(result)) {          ed.settext(result);          ed.setselection(result.length());          // alert user     } } 

give try , luck!


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -