Clear text in EditText when entered

后端 未结 18 1690
醉话见心
醉话见心 2020-11-27 03:44

I\'m trying to set and onclicklistener so that when I click within the edittext element it will clear its current contents. Is there something wrong here? When I compile thi

18条回答
  •  旧时难觅i
    2020-11-27 04:30

    If the use of EditText is not mandatory, you can implement this behavior easily with the new material components:

    
    
                
    
            
    

    You only have to specify the drawable you want for the button that will clear the text and the action that it will execute. To clear the text, you can use iconMode="clear_text", but also "password_toggle" is available.

提交回复
热议问题