如何设置进度对话框取消按钮? [英] How to set cancel button in Progress Dialog?

查看:148
本文介绍了如何设置进度对话框取消按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要设置进度对话框取消按钮。 这是我的code。

i want to set a cancel button in progress dialog. This is my code.

myDialog = new ProgressDialog(BaseScreen.this);
            myDialog.setMessage("Loading...");
            myDialog.setCancelable(false);
            myDialog.show();

我想设置这个进程对话框与onclickListener按钮。 我用这个code。

I want to set a button with onclickListener on this progress Dialog. i use this code.

myDialog.setButton("Cancel", new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                myDialog.dismiss();
                }
            });

但不是为我工作的或类似的听众。 请给我建议,以解决这个问题。

But its or similar listeners not working for me. Kindly suggest me to solve this.

推荐答案

正在使用 SET按钮方法是pcated德$ P $(尽管它应该仍然工作)。此外,您可能需要添加之前显示对话框按钮。尝试:

The setButton method you are using is deprecated (although it should still work). Also, you might want to add the button before showing the dialog. Try:

myDialog = new ProgressDialog(BaseScreen.this);
myDialog.setMessage("Loading...");
myDialog.setCancelable(false);
myDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {
        dialog.dismiss();
    }
});
myDialog.show();

这篇关于如何设置进度对话框取消按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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