我有一个模型的
。
在我的数组列表中存在的所有链接之后,我需要加载我的 android 数组列表
,其中包含---> key : { link : ... , duration : .... }web View
,并在特定的
持续时间内加载它们。
更新:
我尝试了处理程序,但它仍然加载最后一个网页并使 Thread.sleep() 挂起应用程序
最佳答案
您可以使用特定时间间隔的 timerTask 来加载您的列表 url
private static Timer timer;
private TimerTask timerTask;
public void startTimer() {
//set a new Timer
try {
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
//schedule the timer, to wake up every 2 second
timer.schedule(timerTask, AppConstants.bgTaskStartDelay, 2000); //
} catch (Exception e) {
e.printStackTrace();
}
}
// it sets the timer to print the counter every x seconds
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
try {
// you code here to load url from your array
} catch (Exception e) {
e.printStackTrace();
}
}
};
}
关于java - 如何在特定时间段后将新 url 加载到 web View 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58498343/