Example usage for android.app AlertDialog setIcon

List of usage examples for android.app AlertDialog setIcon

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:Main.java

public static void displayInfo(Context context, String title, String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);//from  w  ww.  jav a  2  s  . com
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:Main.java

public static void displayAlert(Context context, String title, String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);/*from  w  w w  .  j a v  a 2s .co m*/
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

public static void deleteSeriesAlert(Context context, final CatalogueDBAdapter dbHelper, final Series series,
        final Runnable onDeleted) {

    // When we get here, we know the names are genuinely different and the old series is used in more than one place.
    String message = "Delete series";
    try {//from  w w  w .j  av a2s . co m
        message = String.format(context.getResources().getString(R.string.really_delete_series), series.name);
    } catch (NullPointerException e) {
        Logger.logError(e);
    }
    final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create();

    alertDialog.setTitle(R.string.delete_series);
    alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
    //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
    alertDialog.setButton2(context.getResources().getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dbHelper.deleteSeries(series);
                    alertDialog.dismiss();
                    onDeleted.run();
                }
            });

    //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
    alertDialog.setButton(context.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alertDialog.dismiss();
                }
            });

    alertDialog.show();
}

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

public static void needLibraryThingAlert(final Context context, final boolean ltRequired,
        final String prefSuffix) {
    boolean showAlert;
    int msgId;//from   w  ww .  j av  a2s  .c  o m
    final String prefName = LibraryThingManager.LT_HIDE_ALERT_PREF_NAME + "_" + prefSuffix;
    if (!ltRequired) {
        msgId = R.string.uses_library_thing_info;
        SharedPreferences prefs = context.getSharedPreferences("bookCatalogue",
                android.content.Context.MODE_PRIVATE);
        showAlert = !prefs.getBoolean(prefName, false);
    } else {
        msgId = R.string.require_library_thing_info;
        showAlert = true;
    }

    if (!showAlert)
        return;

    final AlertDialog dlg = new AlertDialog.Builder(context).setMessage(msgId).create();

    dlg.setTitle(R.string.reg_library_thing_title);
    dlg.setIcon(android.R.drawable.ic_menu_info_details);

    dlg.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.more_info),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    Intent i = new Intent(context, AdministrationLibraryThing.class);
                    context.startActivity(i);
                    dlg.dismiss();
                }
            });

    if (!ltRequired) {
        dlg.setButton(DialogInterface.BUTTON_NEUTRAL,
                context.getResources().getString(R.string.disable_dialogue),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        SharedPreferences prefs = context.getSharedPreferences("bookCatalogue",
                                android.content.Context.MODE_PRIVATE);
                        SharedPreferences.Editor ed = prefs.edit();
                        ed.putBoolean(prefName, true);
                        ed.commit();
                        dlg.dismiss();
                    }
                });
    }

    dlg.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dlg.dismiss();
                }
            });

    dlg.show();
}

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

public static int deleteBookAlert(Context context, final CatalogueDBAdapter dbHelper, final long id,
        final Runnable onDeleted) {

    ArrayList<Author> authorList = dbHelper.getBookAuthorList(id);

    String title;/*from w  ww .  j  av a2 s  . c om*/
    Cursor cur = dbHelper.fetchBookById(id);
    try {
        if (cur == null || !cur.moveToFirst())
            return R.string.unable_to_find_book;

        title = cur.getString(cur.getColumnIndex(CatalogueDBAdapter.KEY_TITLE));
        if (title == null || title.length() == 0)
            title = "<Unknown>";

    } finally {
        if (cur != null)
            cur.close();
    }

    // Format the list of authors nicely
    String authors;
    if (authorList.size() == 0)
        authors = "<Unknown>";
    else {
        authors = authorList.get(0).getDisplayName();
        for (int i = 1; i < authorList.size() - 1; i++) {
            authors += ", " + authorList.get(i).getDisplayName();
        }
        if (authorList.size() > 1)
            authors += " " + context.getResources().getString(R.string.list_and) + " "
                    + authorList.get(authorList.size() - 1).getDisplayName();
    }

    // Get the title      
    String format = context.getResources().getString(R.string.really_delete_book);

    String message = String.format(format, title, authors);
    final AlertDialog alertDialog = new AlertDialog.Builder(context).setMessage(message).create();

    alertDialog.setTitle(R.string.menu_delete);
    alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
    //alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
    alertDialog.setButton2(context.getResources().getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dbHelper.deleteBook(id);
                    alertDialog.dismiss();
                    onDeleted.run();
                }
            });

    //alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
    alertDialog.setButton(context.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alertDialog.dismiss();
                }
            });

    alertDialog.show();
    return 0;

}

From source file:com.eleybourn.bookcatalogue.dialogs.StandardDialogs.java

/**
 * Display a dialog warning the user that goodreads authentication is required; gives them
 * the options: 'request now', 'more info' or 'cancel'.
 *//*  w w w  .  j a va  2  s .c  om*/
public static int goodreadsAuthAlert(final FragmentActivity context) {
    // Get the title      
    final AlertDialog alertDialog = new AlertDialog.Builder(context).setTitle(R.string.authorize_access)
            .setMessage(R.string.goodreads_action_cannot_blah_blah).create();

    alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getResources().getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alertDialog.dismiss();
                    GoodreadsRegister.requestAuthorizationInBackground(context);
                }
            });

    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
            context.getResources().getString(R.string.tell_me_more), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alertDialog.dismiss();
                    Intent i = new Intent(context, GoodreadsRegister.class);
                    context.startActivity(i);
                }
            });

    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    alertDialog.dismiss();
                }
            });

    alertDialog.show();
    return 0;

}

From source file:com.jonathongrigg.apps.spark.MainActivity.java

public void showAboutDialog() {
    final AlertDialog aboutDialog = new AlertDialog.Builder(this).create();
    aboutDialog.setTitle(this.getText(R.string.dialog_title));
    aboutDialog.setMessage(this.getText(R.string.dialog_text));
    aboutDialog.setIcon(R.drawable.ic_menu_info_details);

    aboutDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            aboutDialog.dismiss();/*from   w w  w  . j a v  a  2  s . c om*/
        }
    });

    aboutDialog.show();
}

From source file:org.odk.collect.android.activities.FormChooserList.java

/**
 * Creates a dialog with the given message. Will exit the activity when the user preses "ok" if
 * shouldExit is set to true.// w w  w. j  ava2  s  .  c o m
 */
private void createErrorDialog(String errorMsg, final boolean shouldExit) {

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setMessage(errorMsg);
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON_POSITIVE:
                if (shouldExit) {
                    finish();
                }
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), errorListener);
    alertDialog.show();
}

From source file:org.odk.collect.android.activities.InstanceChooserList.java

private void createErrorDialog(String errorMsg, final boolean shouldExit) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertDialog.setMessage(errorMsg);/*from w ww  .  ja v  a 2  s  .c  om*/
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON_POSITIVE:
                if (shouldExit) {
                    finish();
                }
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), errorListener);
    alertDialog.show();
}

From source file:com.danvelazco.fbwrapper.preferences.FacebookPreferences.java

/**
 * Show an alert dialog with the information about the application.
 *///from   w w w . j a v  a 2 s. co m
private void showAboutAlert() {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(getString(R.string.menu_about));
    alertDialog.setMessage(getString(R.string.txt_about));
    alertDialog.setIcon(R.drawable.ic_launcher);
    alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.lbl_dialog_close),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Don't do anything, simply close the dialog
                }
            });
    alertDialog.show();
}