0

我有一个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();
        }
    }
4

1 回答 1

0

问题不AlertDialog在于onOptionsItemSelected. 是答案。

于 2013-11-29T23:57:53.370 回答