简体   繁体   中英

Android: EditText loses focus when setText is called

I'm creating an Android app which contains a timer that counts down and is displayed in EditTexts. There is another EditText on the page that I would like to be able to edit while the timer is counting down.

The problem is that when I call setText() to update the timer text, the other EditText loses focus. Since the timer is updated every second, the soft keyboard is dismissed after less than a second. Is there a way to prevent this from happening?

I would like to keep the timer running (on screen) while the keyboard is visible, but I can't find any good answers of how to do this.

Any help is appreciated!

我遇到了同样的问题, editText.getText().clear()为我解决了问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM