No Progress Spinner in ProgressDialog

有些话、适合烂在心里 提交于 2019-12-13 15:07:18

问题


I am trying to create a ProgressDialog as seen in just about every app on the Play Store now. I am using the code:

getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ProgressDialog dialog;
                dialog = ProgressDialog.show(getActivity(), "title", "message", true, false);
            }
        });

I have also tried with just the 2 lines inside the Runnable (without creating a thread) from inside a fragment and no matter what I do I can't see the spinner in the ProgressDialog. I'm attaching a screenshot so that you can see what I mean. Somebody PLEASE help me.

Running Android 5.1.1 on a Galaxy S6, all stock OS.

EDIT: Imports are:

import android.app.Fragment;
import android.app.ProgressDialog;


回答1:


Check with style you use res/values/style and add new or change color

styles.xml

  <style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorPrimary">@color/orange</item>
    </style>

actyity

ProgressDialog progressDialog = new ProgressDialog(ProfilActivity.this,R.style.MyDialogTheme);




回答2:


If you are in a fragment use getActivity() instead of this

            ProgressDialog progressDialog = new ProgressDialog(getActivity());
            progressDialog.setMessage("[YOUR MESSAGE]");
            progressDialog.setCancelable(true); // Check as required
            progressDialog.show();*/

This one work for me :)




回答3:


Try this

    ProgressDialog progressDialog = new ProgressDialog(context);
    progressDialog.setMessage("[YOUR MESSAGE]");
    progressDialog.setCancelable(true); // Check as required
    progressDialog.show();


来源:https://stackoverflow.com/questions/32939542/no-progress-spinner-in-progressdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!