How to empty the text in the search box in Android

Requirements: the function of clearing text is added to the relevant search places in the project to increase the user experience and make it easier for users to delete text

Solution process: at the beginning, I felt that it was not easy to realize this thing, mainly because of the layout. I may have worried too much at the beginning. In addition, the product was not pressed too hard at that time, and this function did not have to be realized. But today is different. This is added by the boss. He said that many other applications have this function. There is no way to add it. Try to use the relative layout to realize it. Put a delete button on the upper right of the edit box. When the text is displayed, the delete button is displayed. When the edit box is empty, the delete button is hidden. Layout code

This code is directly intercepted from the project. Some tips are used. The layout writing method used in development is tiled with a background, which has been described in previous articles. In the main program, EditText is mainly used to monitor input. This previous article has also been written. I reviewed it again this time. The code is as follows

The requirements described at the beginning can now be implemented. There is also a background picture. 9. PNG, which can be large or small

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

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
分享
二维码
< <上一篇
下一篇>>