更新时间:2023-11-16 17:02:10
一个计时器任务将无法正常工作,因为它会创建一个不同的线程,只有始发线程可能会触及其观点。
A timer task will not work, as it will create a different thread and only originating thread may touch its views.
有关Android上的preferred方式做到这一点是使用一个处理程序。用乙醚
For android the preferred way to do this is to use a handler. Ether by
textMsg.post( new Runnable(){
public void run(){
doProcessing();
testMesg.setText("bla");
testMsg.postDelayed(this,(1000*10));
}
};
或具有处理程序类的一个实例单独
or having a seperate instance of the Handler class
Handler mHanlder = new Handler();
mHandler.post(runnable);