简体   繁体   English

Android:调用setText时EditText失去焦点

[英]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. 我正在创建一个Android应用程序,其中包含一个倒计时的计时器,并显示在EditTexts中。 There is another EditText on the page that I would like to be able to edit while the timer is counting down. 页面上还有一个EditText,我想在计时器倒计时时进行编辑。

The problem is that when I call setText() to update the timer text, the other EditText loses focus. 问题是当我调用setText()更新计时器文本时,另一个EditText失去了焦点。 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()为我解决了问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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