显示加载屏幕? [英] Showing loading screen?

查看:778
本文介绍了显示加载屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示一个载入画面,而我的双打,经度和纬度,为0。目前,我的对话框甚至不显示,和一个错误来了:

I want to show a loading screen while my doubles, longitude and latitude, are 0. Currently, my dialog doesn't even show, and an error comes:

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 真棒是一个对象 RuchirLocation

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。

How can I fix this? I simply want to show a loading dialog while my variables are 0.

谢谢,

Ruchir

推荐答案

的正确方法是先并尽快显示对话框当你获得这些变量的值,然后关闭该进度对话框。

The proper way is to show the dialog initially and as soon as you get the value of those variables then dismiss the progress dialog.

ProgressDialog pd;

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

而一旦你获得这些变量的值 -

And as soon as you get the value of those variables -

pd.dismiss();

这篇关于显示加载屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆