进度条卡住了

时间:2017-05-23 10:30:37

标签: android dialog android-progressbar

我正在使用库MaterialDialog by afollestad实现自定义对话框,并且我已尝试使用它来显示ProgressDialog。有这样做的方法,在新的MaterialDialog类上调用.show(),或者为类创建变量并调用.build(),以便有可能从另一个方法中解除或显示对话框。问题是,当我使用.show时,进度条运行顺利但我可以忽略它,当我调用.build()方法时,进度条冻结,但我可以解雇或取消。

public class HomeActivity extends BaseActivity implements HomeMvpView {

    MaterialDialog materialDialog;

自定义对话框

public void showProgressDialog(String title, String content, String positiveText, String neutralText, String negativeText){

        String carrefour_blue_color = "#" + Integer.toHexString(ContextCompat.getColor(this, R.color.blue));

        materialDialog = new MaterialDialog.Builder(this)
                .progress(true, 0)
                .progressIndeterminateStyle(true)
                .cancelable(false)
                .canceledOnTouchOutside(false)
                .titleColorRes(R.color.blue)
                .contentColor(Color.parseColor(blue_color)) // notice no 'res' postfix for literal color
                .dividerColorRes(R.color.blue_focused)
                .backgroundColorRes(R.color.white)
                .positiveColorRes(R.color.green)
                .neutralColorRes(R.color.gray)
                .negativeColorRes(R.color.red)
                .widgetColorRes(R.color.blue)
                .buttonRippleColorRes(R.color.yellow)
                .titleGravity(GravityEnum.CENTER)
                .contentGravity(GravityEnum.CENTER)
                .btnStackedGravity(GravityEnum.START)
                .itemsGravity(GravityEnum.END)
                .buttonsGravity(GravityEnum.END)
                .title((title != null ? title : null))
                .content((content != null ? content : null))
                .positiveText((positiveText != null ? positiveText : null))
                .neutralText((neutralText != null ? neutralText : null))
                .negativeText((negativeText != null ? negativeText : null))
                .showListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialog) {
                    }
                })
                .cancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialog) {
                    }
                })
                .dismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                    }
                })
                .build();


    }

稍后我将使用materialDialog.dismiss ...为什么动画会冻结。

0 个答案:

没有答案