android - How to show a "Clear button" after the first character pressed and hide it when the text is ""? -


i need show clear button @ right of edit text , hide when text is"". how can that.

i need know how show , hide when text length>0 or =0, nothing more.

try code

field1.addtextchangedlistener(new textwatcher() {       @override       public void aftertextchanged(editable s) {}       @override            public void beforetextchanged(charsequence s, int start,        int count, int after) {       }      @override         public void ontextchanged(charsequence s, int start,        int before, int count) {        if(s.length() != 0)         // set visibility     }      }); 

Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

html - Not able to access next element of an array javascript -