List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:com.color.kid.kidpaint.dialog.InfoDialog.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w w w . j a va 2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new CustomAlertDialogBuilder(getActivity()); if (mTitleResource != NULL_RESOURCE) { //builder.setTitle(mTitleResource); } int imageResource = mDialogType.getImageResource(); if (imageResource != NULL_RESOURCE) { builder.setIcon(imageResource); } if (mMessageResource != NULL_RESOURCE) { builder.setMessage(mMessageResource); } builder.setNeutralButton(android.R.string.ok, this); return builder.create(); }
From source file:com.oddsoft.tpetrash2.view.activity.MainActivity.java
protected final Dialog onCreateDialog(final int id) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_exclamation_sign)); builder.setCancelable(true);/*ww w. j av a 2 s . c om*/ builder.setPositiveButton(android.R.string.ok, null); //final Context context = this; switch (id) { case DIALOG_WELCOME: builder.setTitle(getResources().getString(R.string.welcome_title)); builder.setMessage(getResources().getString(R.string.welcome_message)); break; case DIALOG_UPDATE: builder.setTitle(getString(R.string.changelog_title)); final String[] changes = getResources().getStringArray(R.array.updates); final StringBuilder buf = new StringBuilder(); for (int i = 0; i < changes.length; i++) { buf.append("\n\n"); buf.append(changes[i]); } builder.setMessage(buf.toString().trim()); break; } return builder.create(); }
From source file:de.eidottermihi.rpicheck.fragment.RebootDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.shutdown_type_title); //fetching the theme-dependent icon TypedValue icon = new TypedValue(); if (getActivity().getTheme().resolveAttribute(R.attr.ic_dialog_shutdown, icon, true)) { builder.setIcon(icon.resourceId); }// w ww . ja v a 2 s . com builder.setItems(R.array.shutdown_options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: // reboot mShutdownDialogListener.onRebootClick(dialog); break; case 1: // halt mShutdownDialogListener.onHaltClick(dialog); default: break; } } }); return builder.create(); }
From source file:at.maui.cheapcast.fragment.DonationsFragment.java
/** * Open dialog/*from www . j a v a 2 s .c o m*/ * * @param icon * @param title * @param message */ void openDialog(int icon, int title, String message) { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setIcon(icon); dialog.setTitle(title); dialog.setMessage(message); dialog.setCancelable(true); dialog.setNeutralButton(R.string.donations__button_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); }
From source file:se.chalmers.dat255.group22.escape.MainActivity.java
private void showAboutDialog() { if (aboutDialog == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.about_dialog_title)); builder.setIcon(R.drawable.ic_launcher); View dialogView = getLayoutInflater().inflate(R.layout.about_dialog, null, false); // Interprets html link tags correctly and makes links clickable TextView repoLink = (TextView) dialogView.findViewById(R.id.about_dialog_repo); repoLink.setMovementMethod(LinkMovementMethod.getInstance()); TextView licenseLink = (TextView) dialogView.findViewById(R.id.about_dialog_license); licenseLink.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(dialogView);/* ww w .j a v a2 s. co m*/ aboutDialog = builder.create(); } // Brings up the dialog aboutDialog.show(); }
From source file:cn.count.easydrive366.DriverLicenseEditActivity.java
private void chooseDriverType() { final JSONArray list = AppSettings.driver_type_list; if (list == null) { return;/*from w ww. ja v a2 s .com*/ } String types = ((TextView) findViewById(R.id.edt_driverlicense_car_type)).getText().toString(); AlertDialog.Builder builder = new AlertDialog.Builder(this); MultiChoiceID.clear(); builder.setIcon(R.drawable.ic_launcher); builder.setTitle(this.getResources().getString(R.string.app_name)); final String[] items = new String[list.length()]; boolean[] checkedItems = new boolean[list.length()]; try { for (int i = 0; i < list.length(); i++) { JSONObject item = list.getJSONObject(i); String code = item.getString("code"); String name = item.getString("name"); String years = item.getString("years"); items[i] = String.format("%s--%s(%s)", code, name, years); if (types.contains(code)) { checkedItems[i] = true; MultiChoiceID.add(i); } else { checkedItems[i] = false; } } } catch (Exception e) { log(e); } builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { if (!MultiChoiceID.contains(which)) MultiChoiceID.add(which); } else { if (MultiChoiceID.contains(which)) { int i_index = MultiChoiceID.indexOf(which); MultiChoiceID.remove(i_index); } } } }); builder.setPositiveButton(this.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // String str = ""; // int size = MultiChoiceID.size(); // for (int i = 0 ;i < size; i++) { // str+= items[MultiChoiceID.get(i)] + ", "; // } // showDialog(str); changeDriverType(); } }); builder.setNegativeButton(this.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); builder.show(); }
From source file:systems.obscure.client.ContactsListFragment.java
private void handleDeleteAllSelected() { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); alert.setTitle(R.string.ConversationListFragment_delete_threads_question); alert.setMessage(/* w w w. ja v a 2 s. c om*/ R.string.ConversationListFragment_are_you_sure_you_wish_to_delete_all_selected_conversation_threads); alert.setCancelable(true); alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Set<Long> selectedConversations = ((ContactListAdapter) getListAdapter()) .getBatchSelections(); if (!selectedConversations.isEmpty()) { new AsyncTask<Void, Void, Void>() { private ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(getActivity(), getActivity().getString(R.string.ConversationListFragment_deleting), getActivity() .getString(R.string.ConversationListFragment_deleting_selected_threads), true, false); } @Override protected Void doInBackground(Void... params) { // DatabaseFactory.getThreadDatabase(getActivity()).deleteConversations(selectedConversations); MessageNotifier.updateNotification(getActivity(), masterSecret); return null; } @Override protected void onPostExecute(Void result) { dialog.dismiss(); if (actionMode != null) { actionMode.finish(); actionMode = null; } } }.execute(); } } }); alert.setNegativeButton(android.R.string.cancel, null); alert.show(); }
From source file:at.jclehner.rxdroid.BackupFragment.java
private void showExceptionDialog(Exception e) { final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity()); ab.setTitle(R.string._title_error);/*from w w w . ja v a2s .c o m*/ ab.setIcon(android.R.drawable.ic_dialog_alert); ab.setPositiveButton(android.R.string.ok, null); ab.setCancelable(true); ab.setMessage(Html .fromHtml("<tt>" + e.getClass().getSimpleName() + "</tt><br/>" + Util.escapeHtml(e.getMessage()))); //ab.show(getFragmentManager(), "create_error"); ab.show(); }
From source file:piuk.blockchain.android.ui.WalletActivity.java
private void timeskewAlert(final long diffMinutes) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.wallet_timeskew_dialog_title); builder.setMessage(getString(R.string.wallet_timeskew_dialog_msg, diffMinutes)); builder.setPositiveButton(R.string.wallet_timeskew_dialog_button_settings, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(android.provider.Settings.ACTION_DATE_SETTINGS)); finish();/* w w w. java 2s .c o m*/ } }); builder.setNegativeButton(R.string.button_dismiss, null); builder.show(); }
From source file:ca.rmen.android.networkmonitor.app.dialog.InfoDialogFragment.java
/** * @return a Dialog with a title, message, and single button to dismiss the dialog. *///from w w w .j a v a2 s . co m @Override @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { Log.v(TAG, "onCreateDialog: savedInstanceState = " + savedInstanceState); Context context = getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(context); Bundle arguments = getArguments(); final int actionId = arguments.getInt(DialogFragmentFactory.EXTRA_ACTION_ID); final int iconId = arguments.getInt(DialogFragmentFactory.EXTRA_ICON_ID); if (iconId > 0) builder.setIcon(iconId); final Bundle extras = arguments.getBundle(DialogFragmentFactory.EXTRA_EXTRAS); builder.setTitle(arguments.getString(DialogFragmentFactory.EXTRA_TITLE)) .setMessage(arguments.getString(DialogFragmentFactory.EXTRA_MESSAGE)); if (getActivity() instanceof InfoDialogListener) { OnClickListener neutralListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { FragmentActivity activity = getActivity(); if (activity == null) Log.w(TAG, "User clicked on dialog after it was detached from activity. Monkey?"); else ((InfoDialogListener) activity).onNeutralClicked(actionId, extras); } }; builder.setNeutralButton(android.R.string.ok, neutralListener); } if (getActivity() instanceof OnCancelListener) builder.setOnCancelListener((OnCancelListener) getActivity()); final Dialog dialog = builder.create(); if (getActivity() instanceof OnDismissListener) dialog.setOnDismissListener((OnDismissListener) getActivity()); return dialog; }