HarshitVaish
10/1/2016 - 7:23 AM

Alert Dialog Implementation

Alert Dialog Implementation

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle("Title here");
        builder.setIcon();
        builder.setMessage("Message here");
        builder.setCancelable(false); // Set if the dialog can be closed by clicking outside the bounds

        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // Handle positive click
            }
        });
        builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // Handle negative click
            }
        });
        builder.setNeutralButton("Don't know", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // Handle neutral click
            }
        });
        //endregion

        //region Show the dialog
        AlertDialog alertDialog = builder.create();
        alertDialog.show();