【发布时间】:2017-06-14 01:05:17
【问题描述】:
您好,我在打开 Activity 时遇到问题。
我通过点击Button 与Intent 通话startActivity()。
我需要等待 4-5 秒,Activity 才会出现在屏幕上。
我知道该怎么做。
itemimg = new ItemsInPacagesImageView(imglist1, this, nazovtripu, 0);
我有 17 次相似的代码(与其他 ImageViews)我在方法中有这个名称为 InitItemimg();
我试着用这个线程把这个方法放在 OnStart 活动上
@Override
public void onStart() {
super.onStart();
timer = new Thread() { // new thread
public void run() {
Boolean b = true;
try {
sleep(20);
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
InitItemimg();;
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
}
}
};
timer.start();
}
但是没有解决我的问题,请问您有什么想法吗?谢谢
【问题讨论】:
标签: java android multithreading android-activity application-start