Showing posts with label Confirmation Dialog. Show all posts
Showing posts with label Confirmation Dialog. Show all posts

Wednesday, February 25, 2015

ANDROID code to show confirmation Dialog

private void showConfirmationDialog() {
         AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(AddNewPurchaseActivity.this);

        alertDialogBuilder.setTitle("TITLE");
        alertDialogBuilder
        .setMessage("MESSAGE ")
        .setCancelable(true)
        .setPositiveButton("No",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {
                openActivity(MainWelcomeActivity.class);           
             }
          })
        .setNegativeButton("Yes",new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog,int id) {               
                openActivity(ABCActivity.class);
            }
        });
       
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();
       
        Button yes = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
        yes.setBackgroundDrawable(getResources().getDrawable(R.color.xprarkgray));
        yes.setTextColor(Color.WHITE);

        Button no = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
        no.setBackgroundDrawable(getResources().getDrawable(R.color.SeaGreen));
        no.setTextColor(Color.WHITE);
    }