Example usage for android.app AlertDialog.Builder setIcon

List of usage examples for android.app AlertDialog.Builder setIcon

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:Main.java

public static void showDialog(Activity context, String strTitle, String strText, int icon) {
    AlertDialog.Builder tDialog = new AlertDialog.Builder(context);
    tDialog.setIcon(icon);
    tDialog.setTitle(strTitle);// www  .  ja  v a 2s.c  o m
    tDialog.setMessage(strText);
    tDialog.setPositiveButton("Sure", null);
    tDialog.show();
}

From source file:Main.java

public static void alertActivityFinish(final Activity activity, String msg) {
    AlertDialog.Builder ad = new AlertDialog.Builder(activity);
    ad.setIcon(activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert)); // Android Resource
    ad.setTitle("Sky Canvas").setMessage(msg).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // finish dialog
            dialog.dismiss();//  ww w  . java  2  s  .c  o  m
            activity.finish();
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

        }
    }).show();
    ad = null;
}

From source file:Main.java

/**
 * Dialog/*from  www.ja  v  a  2  s . c  o m*/
 * @param context
 * @param iconId
 * @param title
 * @param message
 * @param positiveBtnName
 * @param negativeBtnName
 * @param positiveBtnListener
 * @param negativeBtnListener
 * @return
 */
public static Dialog createConfirmDialog(Context context, int iconId, String title, String message,
        String positiveBtnName, String negativeBtnName,
        android.content.DialogInterface.OnClickListener positiveBtnListener,
        android.content.DialogInterface.OnClickListener negativeBtnListener) {
    Dialog dialog = null;
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setIcon(iconId);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton(positiveBtnName, positiveBtnListener);
    builder.setNegativeButton(negativeBtnName, negativeBtnListener);
    dialog = builder.create();
    return dialog;
}

From source file:Main.java

public static void showYesNoPrompt(Context _context, String title, String message,
        OnClickListener onYesListener, OnClickListener onNoListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(_context);
    builder.setTitle(title);//from   ww  w. java  2 s .com
    builder.setIcon(android.R.drawable.ic_dialog_info); // lame icon
    builder.setMessage(message);
    builder.setCancelable(false);
    builder.setPositiveButton("Yes", onYesListener);
    builder.setNegativeButton("No", onNoListener);
    builder.show();
}

From source file:Main.java

public static void showAlertDialog(Context context, String title, String message) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(context);
    dialog.setTitle(title);//from   ww w  .j  a va 2s.co  m
    dialog.setMessage(message);
    dialog.setIcon(android.R.drawable.ic_dialog_alert);
    dialog.setPositiveButton(android.R.string.ok, null);
    dialog.show();
}

From source file:Main.java

public static void showYesNoPrompt(Context _context, String title, String message,
        OnClickListener onYesListener, OnClickListener onNoListener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(_context);
    builder.setTitle(title);//from   w  ww. j  a  v  a2 s .com
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setMessage(message);
    builder.setCancelable(false);
    builder.setPositiveButton("Yes", onYesListener);
    builder.setNegativeButton("No", onNoListener);
    boolean show = true;
    if (_context instanceof Activity) {
        Activity activity = (Activity) _context;
        if (activity.isFinishing()) {
            show = false;
        }
    }
    if (show)
        builder.show();
}

From source file:Main.java

public static AlertDialog showTutorialDialog(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Watch a YouTube video tutorial?");
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setPositiveButton("Watch", new DialogInterface.OnClickListener() {
        @Override//from  w w  w.  ja  v  a2 s  .c o m
        public void onClick(DialogInterface dialog, int which) {
            PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false)
                    .commit();
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://www.youtube.com/watch?v=LhiSWE5-ezM"));
            context.startActivity(browserIntent);
        }
    });

    builder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("firstrun", false)
                    .commit();
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();

    return alert;
}

From source file:com.dimasdanz.kendalipintu.util.CommonUtilities.java

public static void dialogConnectionError(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context, 4);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle(R.string.title_dialog_server_error);
    builder.setMessage(R.string.message_dialog_connection_error);
    builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Activity a = (Activity) context;
            a.finish();/*from  w ww  . ja  v  a  2 s  .  c  o m*/
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:Main.java

public static void showDialogBox(Context context, String title, String msg, int icon) {
    AlertDialog.Builder ad = new AlertDialog.Builder(context);
    ad.setTitle(title);/*from  www. jav  a  2s .c  o  m*/
    ad.setPositiveButton(android.R.string.ok, null);
    if (icon <= 0)
        ad.setIcon(android.R.drawable.ic_dialog_alert);
    else
        ad.setIcon(icon);
    ad.setMessage(msg);
    ad.show();
}

From source file:com.vigek.iotcore.common.Notify.java

public static void CrashReport(final Context cont, final String crashReport) {
    AlertDialog.Builder builder = new AlertDialog.Builder(cont);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setTitle("ERROR");
    builder.setMessage(crashReport);/*from   ww  w  .j av  a 2s  .  co m*/
    builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            // ???
            Intent i = new Intent(Intent.ACTION_SEND);
            // i.setType("text/plain"); //?
            i.setType("message/rfc822"); // 
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { "dustin.guo.sz@qq.com" });
            i.putExtra(Intent.EXTRA_SUBJECT, "Vigek ? - ");
            i.putExtra(Intent.EXTRA_TEXT, crashReport);
            cont.startActivity(Intent.createChooser(i, "???"));
            // ??
            AppManager.getAppManager().AppExit(cont);
        }
    });
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            // ??
            AppManager.getAppManager().AppExit(cont);
        }
    });
    builder.show();
}