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:finalproject.ece558.edu.pdx.ece.brailleblackjack.PlayBlackJackGameFragment.java

/**
 * Display a hint Dialog containing the numerical values on the screen if the player is having
 *  trouble reading the braille characters
 *//*from ww  w .j a  v a  2 s .c o m*/
public void hintDialog() {
    Log.d(TAG, "In hintDialog");
    StringBuilder sb = new StringBuilder();
    int highest_dealer_total;
    int highest_player_total;

    // Grab the player's highest total
    highest_player_total = (player_top_total_value > player_bot_total_value) ? player_top_total_value
            : player_bot_total_value;

    // Grab the player's highest total
    highest_dealer_total = (dealer_top_total_value > dealer_bot_total_value) ? dealer_top_total_value
            : dealer_bot_total_value;

    if (dealer_left_card != null) {
        sb.append("Dealer Left Card: " + dealer_left_card.getCardValue() + "\n");
    }
    sb.append("Dealer Right Card: " + dealer_right_card.getCardValue());
    sb.append("\nDealer Highest Total: " + highest_dealer_total);
    sb.append("\n\nPlayer Left Card: " + player_left_card.getCardValue());
    sb.append("\nPlayer Right Card: " + player_right_card.getCardValue());
    sb.append("\nPlayer Highest Total: " + highest_player_total);

    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getResources().getString(R.string.hint));
    builder.setIcon(R.mipmap.ic_launcher);
    builder.setMessage(sb.toString()).setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });

    // create alert dialog
    AlertDialog alertDialog = builder.create();

    // show it
    alertDialog.show();
}

From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java

/**
 * Called when excel export task is done.
 * // w w w.  ja  v a2s.co  m
 * @param filePath
 */
private void onGameSetExportedToExcelFile(String filePath) {
    // should never happen
    if (filePath == null) {
        UIHelper.showSimpleRichTextDialog(this, this.getString(R.string.msgDbExportFailed),
                this.getString(R.string.titleDbExportFailed));
    }

    else {
        this.tempExcelFilePath = filePath;
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(this.getString(R.string.titleGameSetExportedToExcelFile));
        builder.setMessage(Html.fromHtml(this.getText(R.string.msgGameSetExportedToExcelFile).toString()));
        builder.setPositiveButton(this.getString(R.string.btnOk), this.exportExcelByEmailDialogClickListener);
        builder.setNegativeButton(this.getString(R.string.btnCancel),
                this.exportExcelByEmailDialogClickListener);
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.show();
    }
}

From source file:org.nla.tarotdroid.lib.ui.TabGameSetActivity.java

@Override
public void onBackPressed() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    String dialogTitle = this.gameSet.isPersisted() ? this.getString(R.string.titleExitGameSetYesNoWithDAL)
            : this.getString(R.string.titleExitGameSetYesNo);
    String dialogMessage = this.gameSet.isPersisted()
            ? this.getText(R.string.msgExitGameSetYesNoWithDAL).toString()
            : this.getText(R.string.msgExitGameSetYesNo).toString();

    builder.setTitle(dialogTitle);/*from  w w  w . ja  v a2  s  .  c o m*/
    builder.setMessage(Html.fromHtml(dialogMessage));
    builder.setPositiveButton(this.getString(R.string.btnOk), this.leavingDialogClickListener);
    builder.setNegativeButton(this.getString(R.string.btnCancel), this.leavingDialogClickListener).show();
    builder.setIcon(android.R.drawable.ic_dialog_alert);
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    // Set up variables for a dialog and a dialog builder. Only need one of each.
    Dialog dialog = null;//from   www .  j  a va  2  s.c  o m
    AlertDialog.Builder builder = null;

    // Determine the type of dialog based on the integer passed. These are defined in constants
    // at the top of the class.
    switch (id) {
    case DIALOG_SHOW_HOVER_TEXT:
        //Build and show the Hover Text dialog
        builder = new AlertDialog.Builder(ComicViewerActivity.this);
        builder.setMessage(comicInfo.getAlt());
        builder.setPositiveButton("Open Link...", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                openComicLink();
            }
        });
        builder.setNegativeButton("Close", null);
        dialog = builder.create();
        builder = null;
        break;
    case DIALOG_SHOW_ABOUT:
        //Build and show the About dialog
        builder = new AlertDialog.Builder(this);
        builder.setTitle(getStringAppName());
        builder.setIcon(android.R.drawable.ic_menu_info_details);
        builder.setNegativeButton(android.R.string.ok, null);
        builder.setNeutralButton("Donate", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                donate();
            }
        });
        builder.setPositiveButton("Developer Website", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                developerWebsite();
            }
        });
        View v = LayoutInflater.from(this).inflate(R.layout.about, null);
        TextView tv = (TextView) v.findViewById(R.id.aboutText);
        tv.setText(String.format(getStringAboutText(), getVersion()));
        builder.setView(v);
        dialog = builder.create();
        builder = null;
        v = null;
        tv = null;
        break;
    case DIALOG_SEARCH_BY_TITLE:
        //Build and show the Search By Title dialog
        builder = new AlertDialog.Builder(this);

        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.search_dlg, (ViewGroup) findViewById(R.id.search_dlg));

        final EditText input = (EditText) layout.findViewById(R.id.search_dlg_edit_box);

        builder.setTitle("Search by Title");
        builder.setIcon(android.R.drawable.ic_menu_search);
        builder.setView(layout);
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String query = input.getText().toString();
                Uri uri = comicDef.getArchiveUrl();
                Intent i = new Intent(ComicViewerActivity.this, getArchiveActivityClass());
                i.setAction(Intent.ACTION_VIEW);
                i.setData(uri);
                i.putExtra(getPackageName() + "LoadType", ArchiveActivity.LoadType.SEARCH_TITLE);
                i.putExtra(getPackageName() + "query", query);
                startActivityForResult(i, PICK_ARCHIVE_ITEM);
            }
        });
        builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        builder = null;
        break;
    case DIALOG_FAILED:
        // Probably doesn't need its own builder, but because this is a special case
        // dialog I gave it one.
        AlertDialog.Builder adb = new AlertDialog.Builder(this);
        adb.setTitle("Error");
        adb.setIcon(android.R.drawable.ic_dialog_alert);

        adb.setNeutralButton(android.R.string.ok, null);

        //Set failedDialog to our dialog so we can dismiss
        //it manually
        failedDialog = adb.create();
        failedDialog.setMessage(errors);

        dialog = failedDialog;
        break;
    default:
        dialog = null;
    }

    return dialog;
}

From source file:biz.bokhorst.xprivacy.ActivityApp.java

private void optionKill(final int which) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this);
    alertDialogBuilder.setTitle(R.string.menu_app_kill);
    alertDialogBuilder.setMessage(R.string.msg_sure);
    alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher));
    alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
        @Override//from   w  ww  .j a  v  a  2s. co  m
        public void onClick(DialogInterface dialog, int _which) {
            XApplication.manage(ActivityApp.this, mAppInfo.getPackageName().get(which),
                    XApplication.cActionKillProcess);
            Toast.makeText(ActivityApp.this, getString(R.string.msg_done), Toast.LENGTH_LONG).show();
        }
    });
    alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            });
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
}

From source file:jp.co.noxi.app.NXAlertDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (!mFromBuilder) {
        throw new RuntimeException("Use NXAlertDialog$Builder");
    }/*from ww  w  .  jav  a 2 s.c o m*/

    final Bundle args = getArguments();
    final int theme = args.getInt(ARG_THEME);

    AlertDialog.Builder builder;
    if ((theme == VALUE_NULL) || (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)) {
        builder = new AlertDialog.Builder(getActivity());
    } else {
        builder = newDialogBuilder(theme);
    }

    final CharSequence title = args.getCharSequence(ARG_TITLE);
    if (title == null) {
        setCustomTitle(builder);
    } else {
        builder.setTitle(title);
    }

    final CharSequence message = args.getCharSequence(ARG_MESSAGE);
    if (message != null) {
        builder.setMessage(message);
    }

    final int iconId = args.getInt(ARG_ICON, VALUE_NULL);
    if (iconId != VALUE_NULL) {
        builder.setIcon(iconId);
    }

    final int useInverseBackground = args.getInt(ARG_INVERSE_BACKGROUND);
    if (useInverseBackground != VALUE_NULL) {
        builder.setInverseBackgroundForced(useInverseBackground == VALUE_TRUE);
    }

    // View
    setView(builder);

    // List
    setItems(builder);
    setAdapter(builder);
    setMultiChoiceItems(builder);
    setSingleChoiceItems(builder);

    // Buttons
    setPositiveButton(builder);
    setNegativeButton(builder);
    setNeutralButton(builder);

    return builder.create();
}

From source file:com.PPRZonDroid.MainActivity.java

public void kill_ac(View mView) {

    if (AC_DATA.SelAcInd >= 0) {

        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
        // Setting Dialog Title
        alertDialog.setTitle("Kill Throttle");

        // Setting Dialog Message
        alertDialog.setMessage("Kill throttle of A/C " + AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_Name + "?");

        // Setting Icon to Dialog
        alertDialog.setIcon(R.drawable.kill);

        // Setting Positive "Yes" Button
        alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // User pressed YES button. Send kill string
                send_to_server("dl DL_SETTING " + AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_Id + " "
                        + AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_KillID + " 1.000000", true);
                Toast.makeText(getApplicationContext(),
                        AC_DATA.AircraftData[AC_DATA.SelAcInd].AC_Name + " ,mayday, kill mode!",
                        Toast.LENGTH_SHORT).show();
                MapThrottle.setTextColor(Color.RED);
            }//from www  .ja  v  a2s. c o m
        });

        alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

            }
        });

        // Showing Alert Message
        alertDialog.show();

    } else {
        Toast.makeText(getApplicationContext(), "No AC data yet!", Toast.LENGTH_SHORT).show();
    }
}

From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java

@Override
public void onBackPressed() {
    final AlertDialog.Builder alertbox5 = new AlertDialog.Builder(ViewPagerActivity.this);
    alertbox5.setTitle("Rate Us!");
    alertbox5.setIcon(android.R.drawable.stat_notify_error);

    alertbox5.setMessage(/*from w w w.j  a v a2  s . c  o m*/
            "Please rate us and leave a suggestion so we can enhance this app to your liking! Once you rate, this dialog box won't show again.");
    alertbox5.setNeutralButton("Rate", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface arg0, int arg1) {
            editor.putInt("continuePage", mViewPager.getCurrentItem());
            editor.commit();
            rated = true;
            editor.putBoolean("rated", rated);
            editor.commit();
            String appName2 = "com.qaziconsultancy.thirteenlinequran";
            try {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName2)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appName2)));
            }
        }
    });
    alertbox5.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            editor.putInt("continuePage", mViewPager.getCurrentItem());
            editor.commit();
            finish();
        }
    });

    if (!rated)
        alertbox5.show();
    else {
        editor.putInt("continuePage", mViewPager.getCurrentItem());
        editor.commit();
        finish();
    }

}

From source file:com.pranavpandey.smallapp.permission.PermissionDangerous.java

private void buildPermissionsDialog(final ArrayList<String> permissions, final boolean isRequest) {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    View view = getLayoutInflater().inflate(R.layout.sas_dialog_permission, new LinearLayout(this), false);
    TextView message = (TextView) view.findViewById(R.id.permission_message);
    ViewGroup frame = (ViewGroup) view.findViewById(R.id.permission_frame);

    final ArrayList<String> permissionGroups = new ArrayList<String>();
    for (String permission : permissions) {
        try {/*from   w  ww .j av a2s.  c  o  m*/
            PermissionInfo permInfo = getPackageManager().getPermissionInfo(permission,
                    PackageManager.GET_META_DATA);
            if (!permissionGroups.contains(permInfo.group)) {
                permissionGroups.add(permInfo.group);
            }
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    for (String permissionGroup : permissionGroups) {
        try {
            PermissionGroupInfo permGroupInfo = getPackageManager().getPermissionGroupInfo(permissionGroup,
                    PackageManager.GET_META_DATA);
            frame.addView(new PermissionItem(this, permGroupInfo.loadIcon(getPackageManager()),
                    permGroupInfo.loadLabel(getPackageManager()).toString(),
                    permGroupInfo.loadDescription(getPackageManager()).toString()));
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
    }

    if (isRequest) {
        message.setText(R.string.sas_perm_request_desc);
    } else {
        message.setText(String.format(getString(R.string.sas_format_next_line),
                getString(R.string.sas_perm_request_desc), getString(R.string.sas_perm_request_info)));
    }

    try {
        alertDialogBuilder.setIcon(
                DynamicTheme.createDialogIcon(this, getPackageManager().getApplicationIcon(getPackageName())));
    } catch (Exception e) {
        e.printStackTrace();
    }
    alertDialogBuilder.setTitle(getApplicationInfo().loadLabel(getPackageManager()).toString())
            .setPositiveButton(isRequest ? R.string.sas_perm_request : R.string.sas_perm_continue,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int id) {
                            if (isRequest) {
                                requestPermissions(permissions.toArray(new String[permissions.size()]));
                            } else {
                                openPermissionSettings(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                            }
                        }
                    })
            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    finishPermissionsChecker();
                }
            }).setCancelable(false);

    final AlertDialog dialog = alertDialogBuilder.create();
    dialog.setView(view, 0, SmallUtils.getDialogTopPadding(this), 0, 0);

    showPermissionDialog(dialog);
}

From source file:org.nla.tarotdroid.lib.ui.TabGameSetActivity.java

/**
 * Show publish feed dialog./*from   ww w . j  a v a 2s.c  o m*/
 */
private void showPublishOnFacebookDialog(boolean isLeavingDialog) {
    // check for active internet connexion first
    // see post
    // http://stackoverflow.com/questions/2789612/how-can-i-check-whether-an-android-device-is-connected-to-the-web
    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();

    if (networkInfo != null && networkInfo.isConnected()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(this.getString(R.string.titleFacebookPublish));
        builder.setMessage(Html.fromHtml(this.getString(R.string.msgFacebookPublish)));
        if (isLeavingDialog) {
            builder.setPositiveButton(this.getString(R.string.btnOk),
                    this.publishOnFacebookDialogOrLeaveClickListener);
            builder.setNegativeButton(this.getString(R.string.btnCancel),
                    this.publishOnFacebookDialogOrLeaveClickListener).show();
        } else {
            builder.setPositiveButton(this.getString(R.string.btnOk),
                    this.publishOnFacebookDialogClickListener);
            builder.setNegativeButton(this.getString(R.string.btnCancel),
                    this.publishOnFacebookDialogClickListener).show();
        }
        builder.setIcon(android.R.drawable.ic_dialog_alert);
    } else {
        Toast.makeText(this, this.getString(R.string.titleInternetConnexionNecessary), Toast.LENGTH_LONG)
                .show();
    }
}