在第一个 Activity 中,用户保存了他们的详细信息。单击“保存”按钮后,出现“提示”对话框,询问“确定”或“取消”。如果用户单击“确定”,则开始一个新的 Activity 。
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;
}
最佳答案
我知道为时已晚,但是我想回答这个问题以帮助他人,这对我有用:
Intent intent = new Intent(getContext(),OtherActivity.class);
context.startActivity(intent);
上下文是当前 Activity 的上下文。