android: How to replace a word with another text in edittext using addTextChangedListener? -
i have edittext
. want when use type sentence. after space words changed another. want perform using addtextchangedlistener
only. i'm using following code:
edittext.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { // todo auto-generated method stub } @override public void beforetextchanged(charsequence s, int start, int count, int after) { // todo auto-generated method stub } @override public void aftertextchanged(editable s) { // todo auto-generated method stub } });
edittext.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { } @override public void aftertextchanged(editable str) { editable ab = new spannablestringbuilder(str.tostring().replace("a", "a")); edittext.settext(ab); } @override public void beforetextchanged(charsequence s, int start, int count, int after) { } });
Comments
Post a Comment