在Android中键入时更新TextViews

W0l*_*lf7 1 android textview android-edittext

我正在尝试编写一个Android应用程序,它将更新一些TextViews,因为我在一些EditText视图中输入了一些值(实时更新).我想也许在某种形式下使用while循环可能有所帮助,但我想知道是否有更好的方法.

Ceh*_*ehm 6

是的,有一种更好的方式.只需使用:

textMessage.addTextChangedListener(new TextWatcher(){...}
Run Code Online (Sandbox Code Playgroud)

并使用onTextChanged(...)textwatcher中的函数来修改标签的内容.