java 警告对话框_java – 另一个警告对话框后的警报对话框...

我有一个活动(ImportActivity),其中用户输入一些度量的值并将它们保存到sqlite数据库中.

当用户在导入到数据库后单击“保存”按钮时,我有一个警告对话框(SAVEORBACK_DIALOG_ID),用户可以在此处离开此活动或导入另一个度量.它工作正常.

我的问题是当我尝试在(SAVEORBACK_DIALOG_ID)警告对话之前显示另一个警报对话框(SMS_DIALOG_ID).这是因为我想要求用户发送或不发送短信.

当我运行它时它只显示第二个警告对话框(SAVEORBACK_DIALOG_ID)!

我在活动中:

static final int DATE_DIALOG_ID = 0;

static final int TIME_DIALOG_ID = 1;

static final int SAVEORBACK_DIALOG_ID = 2;

static final int SMS_DIALOG_ID = 3;

我从我的活动中打电话给他们:

// sms dialog(send sms to doctor?yes/no)

showDialog(SMS_DIALOG_ID);

// save or back dialog

showDialog(SAVEORBACK_DIALOG_ID);

这是onCreateDialog方法,我有我的对话框(我删除了一些更容易阅读):

@Override

protected Dialog onCreateDialog(int id) {

switch (id) {

case DATE_DIALOG_ID:

return new DatePickerDialog(this, mDateSetListener, mYear, mMonth,

mDay);

case TIME_DIALOG_ID:

return new TimePickerDialog(this, mTimeSetListener, mHour, mMinute,

false);

case SAVEORBACK_DIALOG_ID:

AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setMessage(

"Information saved successfully ! Add Another Info?")

.setCancelable(false)

.setPositiveButton("No",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,

int id) {

ImportActivity.this.finish();

}

})

.setNegativeButton("Yes",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,

int id) {

dialog.cancel();

// get the new date

// Clearing the fields & update date/time

// textviews

}

});

AlertDialog dialog = builder.create();

return dialog;

// case sms dialog

case SMS_DIALOG_ID:

AlertDialog.Builder builder2 = new AlertDialog.Builder(this);

builder2.setMessage("High blood pressure ! Send sms to doctor?")

.setCancelable(false)

.setPositiveButton("No",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,

int id) {

dialog.cancel();

// do nothing - just continue

}

})

.setNegativeButton("Yes",

new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,

int id) {

dialog.cancel();

// try to send sms - report status

}

});

AlertDialog dialog2 = builder2.create();

return dialog2;

//

}

return null;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值