我想每10秒更新一次视图,但我该怎么做?
我该怎么做?我看过一些样本使用“Run()”和“Update()”,但是当我尝试它时,这似乎没有任何帮助,任何想法?
现在我有:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
// Vitamio.isInitialized(this);
Vitamio.isInitialized(getApplicationContext());
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.videoplay);
Log.d("url=", getIntent().getStringExtra("url"));
url = getIntent().getStringExtra("url");
init();
}
答案 0 :(得分:0)
如果您想每10秒更新View
,则必须调用一个帖子。在onCreate()方法中添加以下代码:
Thread t = new Thread() {
@Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(10000); // every 10s
runOnUiThread(new Runnable() {
@Override
public void run() {
// update View here!
}
});
}
} catch (InterruptedException e) {
}
}
};
t.start();