ProgressDialog在UIThread未显示ProgressDialog、UIThread

2023-09-04 06:17:08 作者:国际撩妹一把手

我创建使用谷歌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();

    }
 

解决方案

用于这是一个解决方案:

自定义progressdialog怎么setmessage

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/