Android - progressDialog.show() 和 ProgressDialog.show() 有什么区别? [英] Android - What is difference between progressDialog.show() and ProgressDialog.show()?

查看:35
本文介绍了Android - progressDialog.show() 和 ProgressDialog.show() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是,ProgressDialog 静态方法 show() 的返回值和该类实例的非静态方法 show 的返回值有什么区别?

I mean, what is difference between return value of ProgressDialog static method show() and the non-static method show of an instance of that class?

是否有任何理由更喜欢这种策略

Is there any reason to prefer this strategy

ProgressDialog pd = new ProgressDialog(mActivity);
pd.setTitle(mTitle);
pd.setMessage(mMessage);
pd.show();

为此:

ProgressDialog pd = ProgressDialog.show(mActivity,mTitle,mMessage);

针对特定情况?

推荐答案

在我看来,正确"的方法取决于您的使用情况.静态 show( ... ) 方法正在执行与您相同的步骤:

In my opinion, the "correct" method would depend on your usage. The static show( ... ) methods are performing the same steps you are:

public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message) {
    return show(context, title, message, false);
}

public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate) {
    return show(context, title, message, indeterminate, false, null);
}

public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate, boolean cancelable) {
    return show(context, title, message, indeterminate, cancelable, null);
}

public static ProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate,
        boolean cancelable, OnCancelListener cancelListener) {
    ProgressDialog dialog = new ProgressDialog(context);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(cancelListener);
    dialog.show();
    return dialog;
}

您可以看到,对静态show 方法 参数的任何调用都以构造一个ProgressDialog 结束,并将调用实例方法show().

You can see that any calls to the static show methods with parameters just ends up constructing a ProgressDialog and will call the instance method show().

使用静态 show( ... ) 方法只是让您可以方便地使用一行代码显示基本的 ProgressDialog.

Using the static show( ... ) methods just make it convenient for you to display a basic ProgressDialog using one line of code.

这篇关于Android - progressDialog.show() 和 ProgressDialog.show() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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