ProgressDialog在UIThread未显示 [英] ProgressDialog not shown in UIThread
本文介绍了ProgressDialog在UIThread未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建使用谷歌API的lib地图。因为mapwidget需要很长的时间来加载我试图增加一个装载通知,但它没有示出。我可以在普通线程,虽然显示progressDialog。为什么此对话框不显示?
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
progressDialog = ProgressDialog.show(这一点,请等待,地图=加载,假的,真正的);
//setContentView(R.layout.map);
runOnUiThread(新的Runnable(){
公共无效的run(){
尝试{
Log.d(调试,之前的setContentView); // 13:36:25
的setContentView(R.layout.map);
Log.d(调试,后的setContentView); // 13:36:39
}赶上(例外五){}
progressDialog.dismiss();
}});
initMap();
initGps();
}
解决方案
用于这是一个解决方案:
http://mindtherobot.com/blog / 159 / Android系统的胆量,介绍到活套和 - 处理器/
I'm creating a map using the google api lib. Because the mapwidget takes a long time to load I'm trying to add a loading notification, but it isn't shown. I can show the progressDialog in regular threads though. How come this dialog isn't shown?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progressDialog = ProgressDialog.show(this, "Please Wait", "Map = loading",false,true);
//setContentView(R.layout.map);
runOnUiThread(new Runnable(){
public void run() {
try{
Log.d("debug", "before setContentView"); //13:36:25
setContentView(R.layout.map);
Log.d("debug", "after setContentView"); //13:36:39
} catch (Exception e) { }
progressDialog.dismiss();
}});
initMap();
initGps();
}
解决方案
Used this as a solution:
http://mindtherobot.com/blog/159/android-guts-intro-to-loopers-and-handlers/
这篇关于ProgressDialog在UIThread未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文