public class DisplayTimeThread extends Thread{
yourDialog parent; //这个yourDialog是你的UI句柄
public DisplayTimeThread(yourDialog dlg) {
parent = dlg;
}
public void run(){
try{
....你的处理
parent.setTimeLabel(xxx);//这里就是设定parent的时间label了
sleep(1);//Sleep多少秒你自己决定
}
}catch(Exception e){}
}
}
然后在你的UI里
DisplayTimeThread timeTread = new DisplayTimeThread(this);
timeThread.start();
总之,只要能将你希望显示时间的那个控件句柄传到线程里就可以实现
yourDialog parent; //这个yourDialog是你的UI句柄
public DisplayTimeThread(yourDialog dlg) {
parent = dlg;
}
public void run(){
try{
....你的处理
parent.setTimeLabel(xxx);//这里就是设定parent的时间label了
sleep(1);//Sleep多少秒你自己决定
}
}catch(Exception e){}
}
}
然后在你的UI里
DisplayTimeThread timeTread = new DisplayTimeThread(this);
timeThread.start();
总之,只要能将你希望显示时间的那个控件句柄传到线程里就可以实现
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货