小编SAU*_*_12的帖子

如何通过选择确定按钮在AlertDialog弹出窗口中启动新的活动类

第一项活动是用户保存其详细信息.单击保存按钮后,Alertdialog询问确定或取消.如果用户点击确定,则开始新活动.

    protected final Dialog onCreateDialog(final int id) {
    Dialog dialog = null;
    switch(id) {
    case DIALOG_ID:
        AlertDialog.Builder builder = new AlertDialog.Builder(AppointInformation.this);
        builder.setMessage("Information saved successfully ! Add Another Info?")
        .setCancelable(false)
        .setPositiveButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {

startActivity(new Intent(((Dialog)dialog).getContext(),CheckPatient.class));    
          }
        })
        .setNegativeButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        AlertDialog alert = builder.create(); 
        dialog = alert;
        break;

    default:

    }
    return dialog;
  }
Run Code Online (Sandbox Code Playgroud)

android button

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

button ×1