AlertDialog inside alertdialog android

后端 未结 4 2105
佛祖请我去吃肉
佛祖请我去吃肉 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:01

    I found the way might be it will be helpful for someone so thats why i am sharing:

    //2nd Alert Dialog
                    AlertDialog.Builder alertDialogBuilderSuccess = new AlertDialog.Builder(
                            context);
                    alertDialogBuilderSuccess.setTitle("TopUp Success");
                    // set dialog message
                    alertDialogBuilderSuccess
                            .setMessage(
                                    "You voucher is printed, please go to the cashier.")
                            .setCancelable(false)
                            .setIcon(R.drawable.ic_launcher2)
                            .setPositiveButton("Confirm",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog, int id) {
    
                                            finish();
                                        }
                                    });
    
                    // create alert dialog
                    final AlertDialog alertDialogSuccess = alertDialogBuilderSuccess.create();
    
    
    
    
    
    
    
    
                    //////////////////////////////////
                    //1st Alert
                    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                            context);
                    alertDialogBuilder.setTitle("TopUp Request");
                    // set dialog message
                    alertDialogBuilder
                            .setMessage(
                                    "Please confirm: " + vendor_name + ", "
                                            + tvLoadAmount.getText())
                            .setCancelable(false)
                            .setIcon(R.drawable.ic_launcher2)
                            .setPositiveButton("Confirm",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog, int id) {
    
                                            //calling the second alert when it user press the confirm button
                                            alertDialogSuccess.show();
                                        }
                                    })
                            .setNegativeButton("Cancel",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog, int id) {
                                            dialog.cancel();
                                        }
                                    });
    
                    // create alert dialog
                    AlertDialog alertDialog = alertDialogBuilder.create();
    
                    // show it
                    alertDialog.show();
    

提交回复
热议问题