timer - Android: How to clear EditText on timeout? -


i want clear edittext if e.g. 5 secs has passed last edit. added textchangedlistener edittext. textchangedlistener used timer tries clear edittext in run() method. however, application crashes, because according debugger, edittext.settext("") being called "wrong thread". so, what's best way implement behavior?

i have qt background , cannot believe hard in android :) qt , c++11 implementation of clearing text edit widget on timeout 3 lines of code.

the problem timer runs on background thread != ui thread. quick fix, can instantiate , hander , use postdelayed method. runnable ru on ui thread, after delay


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -