我是新来的,我想知道如何在不使用线程的情况下在android中使用延迟。 我正在使用Handler
Handler handler=new Handler();
Thread r=new Thread () {
public void run() {
// Your next task
}
};
handler.postDelayed(r, 30000);
答案 0 :(得分:1)
替换Thread r = new Thread with Runnable
Handler handler=new Handler();
Runnable r=new Runnable() {
public void run() {
// Your next task
}
};
handler.postDelayed(r, 30000);
答案 1 :(得分:-1)
试试这个
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// Your next task
}
}, 30000);