Java – set EditText to a single line so that it loses focus after pressing enter
•
Java
I use EditText in my code and compare its contents with a string when I click a button
setSingleLine(true);
Prevent this But pressing enter now will cause EditText to lose focus Why is it like this? How can I solve it?
Solution
Try using this Android: lines = "1" in the layout XML of EditText
This will treat the Enter key as a new line and the focus will not loosen Although existing text may be invisible because it has only one line, it moves up and hides
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
二维码