我正在使用google api lib创建地图。因为mapwidget需要很长时间才能加载我正在尝试添加加载通知,但是没有显示。我可以在常规线程中显示progressDialog。为什么没有显示这个对话框?
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();
}
答案 0 :(得分:1)
为ProgressDialog
设置MapActivity
是没有意义的,因为“mapwidget需要很长时间才能加载”,因为你无法知道MapView
何时完成加载,所以你无法知道何时关闭对话框。 setContentView()
本身应该很快运行;地图图块的实际加载是异步发生的。
请注意,显示MapView
所需的时间主要取决于返回Google地图服务器的互联网连接。在大多数情况下,它不需要特别长,当然不足以保证ProgressDialog
。
答案 1 :(得分:0)