我有一个alertDialog
我正在创建另一个alertDialog
. 问题是第一个alertDialog
弹出两次。因此,第二个alertDialog
也被创建了两次。这是我的代码-
public void navigationMenu() {
AlertDialog.Builder builder = new AlertDialog.Builder(
getSherlockActivity());
String[] items = { "Current Location", RajputanaGrnd.NAME,
NCCOffice.NAME, NewMech.NAME, ChemGrounds.NAME, Rampur.NAME,
"Swatantrata Bhavan Ground", ElectDept.NAME, ABLT.NAME };
builder.setTitle("From:");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
AlertDialog.Builder builder1 = new AlertDialog.Builder(
getSherlockActivity());
String[] items = { RajputanaGrnd.NAME, NCCOffice.NAME,
NewMech.NAME, ChemGrounds.NAME, Rampur.NAME,
"Swatantrata Bhavan Ground", ElectDept.NAME, ABLT.NAME };
builder1.setTitle("To:");
builder1.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert1 = builder1.create();
alert1.show();
}
});
AlertDialog alert = builder.create();
if (!alert.isShowing()) {
alert.show();
}
}