Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

In this page you can find the example usage for android.app AlertDialog setTitle.

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:Main.java

public static AlertDialog showAlertMessage(String title, String message, Context context) {
    final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);//  w w  w  .ja v  a2s .c  o  m
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            alertDialog.dismiss();
        }
    });
    alertDialog.show();
    return alertDialog;
}

From source file:Main.java

static public void ShowAlert(String title, String message) {
    tempTitle = title;//from  w ww .jav  a2s  .  c o m
    tempMessage = message;
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
            alertDialog.setTitle(tempTitle);
            alertDialog.setMessage(tempMessage);
            alertDialog.show();
        }
    });
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void showAlert(final String title, final String msg, final Context context) {

    Activity a = (Activity) context;//from  ww w .  j a  va 2s .co m
    a.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            AlertDialog alertDialog = new AlertDialog.Builder(context).create();
            alertDialog.setTitle(title);
            alertDialog.setMessage(msg);
            alertDialog.setButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    dialog.cancel();
                }
            });
            alertDialog.show();
        }
    });
}

From source file:Main.java

public static AlertDialog AlertDialogSingle(final Context context, String Title, String Message,
        String ButtonName) {/*  ww w.j  a  v  a2s  . c  o m*/
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();

    // Setting Dialog Title
    alertDialog.setTitle(Title);

    // Setting Dialog Message
    alertDialog.setMessage(Message);

    // Setting OK Button
    alertDialog.setButton(ButtonName, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(context, "You clicked on OK", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });

    // Showing Alert Message
    return alertDialog;
}

From source file:Main.java

public static void showAlertDialog(Context context, String title, String message) {
    AlertDialog dialog = new AlertDialog.Builder(context).create();
    dialog.setCancelable(true);/*from w ww  . ja va  2 s .  c o m*/
    dialog.setMessage(message);
    dialog.setTitle(title);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    dialog.show();
}

From source file:Main.java

/**
 * showInformationDialog//from  w w  w  .  j ava 2 s.c  om
 *
 * @param title
 * @param message
 * @param context
 * @return
 */
public static AlertDialog showInformationDialog(String title, String message, Context context) {

    AlertDialog.Builder alt_bld = new AlertDialog.Builder(context);
    alt_bld.setMessage(message);
    alt_bld.setCancelable(false);
    alt_bld.setPositiveButton("Aceptar", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    AlertDialog alert = alt_bld.create();

    // Title for AlertDialog
    alert.setTitle(title);

    alert.show();
    return alert;
}

From source file:Main.java

/**
 * showInformationDialog/*from ww w.  j  ava2s.  c  o m*/
 *
 * @param title
 * @param message
 * @param context
 * @param positiveListener
 * @param showNegativeOption
 */
public static void showInformationDialog(String title, String message, Context context,
        DialogInterface.OnClickListener positiveListener, boolean showNegativeOption) {

    AlertDialog.Builder alt_bld = new AlertDialog.Builder(context);
    alt_bld.setMessage(message);
    alt_bld.setCancelable(false);
    alt_bld.setPositiveButton("Aceptar", positiveListener);
    if (showNegativeOption) {
        alt_bld.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });
    }

    AlertDialog alert = alt_bld.create();

    // Title for AlertDialog
    alert.setTitle(title);

    alert.show();
}

From source file:Main.java

public static void showMsgBox(Context c, String title, String msg) {
    AlertDialog ad = new AlertDialog.Builder(c).create();
    ad.setCancelable(false); // This blocks the 'BACK' button
    ad.setMessage(msg);//from   w  w w .j  a va  2  s .  c  om
    ad.setTitle(title);
    ad.setButton(OK, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    ad.show();
}

From source file:com.crea_si.eviacam.wizard.WizardUtils.java

static void checkEngineAndFinishIfNeeded(final Activity a) {
    AccessibilityServiceModeEngine engine = MainEngine.getAccessibilityServiceModeEngine();
    if (engine == null || !engine.isReady()) {
        // Engine is not ready anymore
        final Resources res = a.getResources();
        AlertDialog ad = new AlertDialog.Builder(a).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setTitle(res.getText(R.string.eva_not_running));
        ad.setMessage(res.getText(R.string.eva_not_running_summary));
        ad.setButton(DialogInterface.BUTTON_NEUTRAL, res.getText(R.string.close),
                new DialogInterface.OnClickListener() {
                    @Override/*from w  w  w. j  a va  2  s.c  o m*/
                    public void onClick(DialogInterface dialog, int which) {
                        finishWizard(a);
                    }
                });
        ad.show();
    }
}

From source file:org.cocos2dx.cpp.AppActivity.java

public static void onQuitDialogShow() {
    AlertDialog.Builder builder = new Builder(getContext());
    AlertDialog dialog = builder.create();
    dialog.setTitle("??");
    dialog.setButton(AlertDialog.BUTTON_POSITIVE, "", new DialogInterface.OnClickListener() {

        @Override/*from   w  w w.  ja v a  2 s .  c o m*/
        public void onClick(DialogInterface arg0, int arg1) {
            System.exit(0);
        }
    });
    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, "?", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            arg0.dismiss();
        }
    });
    dialog.show();
}