AlertDialog inside alertdialog android

后端 未结 4 2106
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-18 07:25

I am trying to add an alertdialog within an alertdialog.But not able to see the second alertdialog..please help me here is my code shown

AlertDialog alertDia         


        
4条回答
  •  天涯浪人
    2020-12-18 08:08

    It is gonna be a late answer but you can create an AlertDialog inside onClickListener just like this:

    public void onClick(DialogInterface dialog, int which) {
        if (options[which] == "Manage") {
          //Do smtg
        } else {
            dialog.dismiss();
            final AlertDialog alert;
    
            AlertDialog.Builder dialog2 = new AlertDialog.Builder(CategoryPage.this);
            alert = dialog2.create();
            alert.setTitle("Delete " + title + "?");
            alert.setMessage("Are you sure you want to delete this category?");
    
            alert.setButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    Toast.makeText(CategoryPage.this, "YESS", Toast.LENGTH_LONG).show();
                }
            });
    
            alert.setButton2("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                    alert.dismiss();
                }
            });
    
            alert.show();
        }
    }
    

提交回复
热议问题