In Android, use EditText to click Select all and click cancel all again

Recently, when developing a browser, I encountered such a demand: when clicking the address bar, I need to select all and call up the keyboard, and click again to cancel the selection of all and display the cursor. When clicking other positions on the screen except the address bar, the keyboard is hidden and the cursor is hidden.

Most browsers have this logic, which can improve the user experience and reduce operations.

The code is very simple. I simplified the logic here. The page has only one EditText.

The layout file is as follows: there are two attributes to note

Complete layout file

**mainactivity.java

Two code snippets need to be noted

The above is what Xiaobian introduced to you. In Android, use EditText to click Select all and click Cancel select all again. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>