显示加载屏幕?

时间:2016-03-26 16:33:22

标签: java android arrays string algorithm

我希望在我的双打,经度和纬度为0时显示加载屏幕。目前,我的对话框甚至无法显示,并且出现错误:

while(awesome.longitude == 0 && awesome.latitude == 0){

            Log.v(TAG, "In While");

            ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "",
                    "Fetching Location...Please wait. If this takes too long, try again.", true);

            dialog.show();

        }

经度和纬度是类RuchirLocation中的变量,awesomeRuchirLocation的对象

while循环通过,但对话框不显示。然后,循环约50次后,我收到此错误:

 Caused by: java.lang.RuntimeException: Could not read input channel file descriptors from parcel.

指着:

        ProgressDialog dialog = ProgressDialog.show(MainActivity.this, "",
                "Fetching Location...Please wait. If this takes too long, try again.", true);

我该如何解决这个问题?我只是想在我的变量为0时显示加载对话框。

谢谢,

Ruchir

1 个答案:

答案 0 :(得分:0)

正确的方法是最初显示对话框,一旦获得这些变量的值,就会关闭进度对话框。

ProgressDialog pd;

if(awesome.longitude == 0 && awesome.latitude == 0){
    pd = new ProgressDialog(//context here);
    pd.setMessage("Loading...")
    pd.show();
}

一旦你得到这些变量的值 -

pd.dismiss();