How can I do something, 0.5 second after text changed in my EditText?

前端 未结 14 1223
渐次进展
渐次进展 2020-12-23 08:49

I am filtering my list using an EditText. I want to filter the list 0.5 second after user has finished typing in EditText. I used the afterTextChanged

14条回答
  •  盖世英雄少女心
    2020-12-23 09:30

    How do you determine that they have finished writing? That the edittext loses focus? Then there is setOnFocusChangedListener.

    Responding to latest edit in question: If you want to wait a specific time after the latest key stroke, then you have to start up a thread at the first keypress (use TextWatcher). Constantly register the time of the latest key stroke. Let the thread sleep to the the time of the latest keystroke + 0.5 seconds. If the timestamp of the latest keystroke has not been updated, do whatever you had intended.

提交回复
热议问题