我想在我的编码中添加对话框。该对话框能够弹出。假设用户按下确定按钮后对话框将关闭,但对话框自动关闭。这是我的代码。任何问题?
private void updataAccount(int type){
Iterator<AccountData> iteratorSort = commondata.account.values().iterator();
while (iteratorSort.hasNext()){
AccountData data = iteratorSort.next();
if(data.id == Integer.parseInt(accountId[account_spn.getSelectedItemPosition()]))
{
if(type == INCOME_MODE){
data.balance = data.balance+Double.parseDouble(value);
commondata.updateAccount(data);
}else if(type == PAYOUT_MODE){
data.balance = data.balance-Double.parseDouble(value);
commondata.updateAccount(data);
if(data.balance < 0)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder
.setTitle("Care Money")
.setMessage("Your amount in this account is negative!")
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
return;
}
}