【问题标题】:How to start progress dialog on button click of alert dialog in android?如何在android中单击警报对话框的按钮时启动进度对话框?
【发布时间】:2012-08-31 06:42:13
【问题描述】:

我想在单击警报对话框的“是”按钮时启动进度对话框。但是当我运行它时。它给了我一个窗口已经集中的警告,忽略了焦点增益。它有时有效,有时会发出警告。 并且进度对话框不会启动。请提供一些建议

【问题讨论】:

标签: android progressdialog android-alertdialog


【解决方案1】:

例如——

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AlertDialog.Builder ab = new AlertDialog.Builder(this);
    ab.setMessage("Choose Yes/No :");
    ab.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            // TODO Auto-generated method stub
            arg0.dismiss();
            ProgressDialog pd = new ProgressDialog(PDActivity.this);
            pd.setMessage("test");
            pd.show();
            pd.setCancelable(true);
        }
    });

    ab.setNegativeButton("No", new DialogInterface.OnClickListener() {

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

        }
    });
    ab.show();
}

像上面那样尝试..

【讨论】:

    【解决方案2】:

    在启动进度对话框之前关闭警报对话框。

    【讨论】:

      【解决方案3】:

      当点击是按钮时,首先关闭警报对话框然后启动进度对话框。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多