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

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 -