Android EditText: select all text while touch and clear when user starts typing.

前端 未结 6 1061
生来不讨喜
生来不讨喜 2021-02-19 03:28

I have a edit text in my app. When the user touches the edit text the whole text should be selected and when he starts typing text should be cleared. An example is browser addre

6条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 04:07

    Add attribute to your main.xml file:

    android:selectAllOnFocus="true"
    

    Then all text will be selected and when user type something that will remove it.

提交回复
热议问题