Android AlertDialog Create showSingleDialog(Context context, String title, String msg, boolean cancelable)

Here you can find the source of showSingleDialog(Context context, String title, String msg, boolean cancelable)

Description

Function to create AlertDialog

Parameter

Parameter Description
context a parameter
title dialog title
msg dialog message
cancelable cancelable when back button clicked

Declaration

public static void showSingleDialog(Context context, String title,
        String msg, boolean cancelable) 

Method Source Code

//package com.java2s;

import android.app.AlertDialog;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;

public class Main {
    /**//  w  w  w.  j a  v a  2s. co  m
     * Function to create AlertDialog
     * 
     * @param context
     * @param title
     *            dialog title
     * @param msg
     *            dialog message
     * @param cancelable
     *            cancelable when back button clicked
     */
    public static void showSingleDialog(Context context, String title,
            String msg, boolean cancelable) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage(msg).setCancelable(cancelable).setTitle(title)
                .setPositiveButton("OK", new OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

Related

  1. showAlertDialog(Context context, String title, String message, String btnString, DialogInterface.OnClickListener onClickListener)
  2. newYesNoDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId, OnClickListener listener)
  3. newMessageDialog(final Context context, String dialogTitle, String screenMessage, int iconResourceId)
  4. showAuthenticatedDialog(Context context, String title, String text)
  5. showMessageDialog(Context context, String title, String strText)
  6. getInstallationDialog(final Context context)
  7. showDialog(Context context, String title, String message)
  8. makeDialogBox(Context context, String title, String message, String cancleButton, DialogInterface.OnClickListener cancelCallBack, String okayButton, DialogInterface.OnClickListener okayCallBack)
  9. simpleDialogBox(Context context, String message)