我在 Lollipop 上的 ProgressDialog 中看不到进度微调器

I can't see the progress spinner in ProgressDialog on Lollipop

使用 ProgressDialog 制作应用程序,它在 JellyBean 上显示正常,但在使用 Lollipop 进行测试时,我只看到标题和消息,没有进度条。我正在使用

compile 'com.android.support:appcompat-v7:22.2.0'

支持库和 AppCompatActivity

密码是:

 ProgressDialog progressDialog = new ProgressDialog(AddBuddyActivity.this);
 progressDialog.setMessage("Loading...");
 progressDialog.setCancelable(false);
 progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
 progressDialog.show();

您可以查看我发布的关于同一主题的另一个问题 here

注意:你可以看到这个问题的伪重复here。 link中的那个更彻底一点,但两者的解决方案相同。

答案似乎是,如果用户在开发人员选项中关闭了转换,您在 ProgressDialog(即 Progress Spinner)中的动画将不会显示。打开它们并重新启动应用程序,您将看到微调器!

一种允许在关闭这些设置的情况下播放动画的解决方案似乎是创建一个自定义对话框,诚然,这可能比默认的 ProgressDialog 看起来更好。

并且,作为对试图滥用 ProgressDialog 的人的公平警告,请注意开发人员的这些话 documentation

Android includes another dialog class called ProgressDialog that shows a dialog with a progress bar. However, if you need to indicate loading or indeterminate progress, you should instead follow the design guidelines for Progress & Activity and use a ProgressBar in your layout.

据此,我认为使用它们进行长时间的网络调用是可以的,而加载信息或进行长时间的本地处理应该使用其他进度组件之一来指示。

我在 Lollipop 中使用它。请让我知道这对你有没有用。 我使用的支持库是 android-support-v4.jar

import android.app.ProgressDialog;

ProgressDialog dialog = ProgressDialog.show(this, "Title", "Message ", true, true);//Put this where you need it

这对我来说效果很好: 带有 4.4.2 的 Droid Razor M 三星 Note 4 5.0.1 三星 Galaxy 6 Edge 5.1.1