我是Android新手,我正在尝试使用线程构建一个读取语音信号值的应用程序,并使用处理程序在ui上显示值。 Recording thread that reads the values and sends message to handler。Handler for the recording thread message
我实际上需要textview每3秒更新一次,但变量值的值会更快地更新。在包含记录线程的代码中,我想在每3秒后发送一条消息(可以看出,while循环运行3秒)。但我无法做到这一点。请帮忙!!
答案 0 :(得分:1)
您可以使用Handler类:
final Handler handler = new Handler();
handler.post(new Runnable(){
@Override
public void run(){
// change your text here
handler.postDelayed(this, 3*1000);
}
});
答案 1 :(得分:0)
使用处理程序或TextView:
textView.postDelay(new Runnable());