Code example for AlertDialog

Methods: setButton

0
                        0, 
                        context.getString(title),
                        false)); 
        builder.setView(createMessage(context, message));
        AlertDialog dialog = builder.create();
        dialog.setButton(
                DialogInterface.BUTTON_POSITIVE, context.getString(button1), onClickListener);
        dialog.setButton(
                DialogInterface.BUTTON_NEGATIVE, context.getString(button2), onClickListener);
        return dialog;
    } 
 
    /** 
     * Method that creates a three buttons question {@link AlertDialog}. 
     * 
     * @param context The current context 
     * @param button1 The resource identifier of the text of the button 1 (POSITIVE) 
     * @param button2 The resource identifier of the text of the button 2 (NEUTRAL) 
     * @param button3 The resource identifier of the text of the button 3 (NEGATIVE) 
     * @param title The resource id of the title of the alert dialog 
     * @param message The message of the alert dialog