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:co.carlosandresjimenez.android.gotit.FollowRequestFragment.java

public void openRejectDialog(final String userEmail) {

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
    alertDialogBuilder.setTitle("Reject request");

    // set dialog message
    alertDialogBuilder.setMessage(getString(R.string.dialog_follow_reject, userEmail)).setCancelable(false)
            .setPositiveButton(R.string.action_yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onRejectRequested(userEmail);
                    dialog.dismiss();//from   w w  w . j a v a  2  s. c  o  m
                    showProgressDialog(getString(R.string.progressdialog_follow_reject));
                }
            }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.setCanceledOnTouchOutside(false);

    // show it
    alertDialog.show();
}

From source file:co.carlosandresjimenez.android.gotit.FollowRequestFragment.java

public void openAcceptDialog(final String userEmail) {

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_info);
    alertDialogBuilder.setTitle("Accept request");

    // set dialog message
    alertDialogBuilder.setMessage(getString(R.string.dialog_follow_accept, userEmail)).setCancelable(false)
            .setPositiveButton(R.string.action_yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onAcceptRequested(userEmail, true);
                    dialog.dismiss();/*  ww w. j a v a2s .c o m*/
                    showProgressDialog(getString(R.string.progressdialog_follow_accept));
                }
            }).setNegativeButton(R.string.action_no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onAcceptRequested(userEmail, true);
                    dialog.dismiss();
                    showProgressDialog(getString(R.string.progressdialog_follow_reject));
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.setCanceledOnTouchOutside(false);

    // show it
    alertDialog.show();
}

From source file:com.mchp.android.PIC32_BTSK.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    String mTitle = this.getActivity().getApplicationContext().getString(R.string.app_name) + " "
            + mVersionName;/*from   ww  w  .java  2s  .co m*/
    builder.setTitle(mTitle);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.setMessage(mAbout).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });

    // Create the AlertDialog object and return it
    return builder.create();
}

From source file:eu.basicairdata.graziano.gpslogger.FragmentPlacemarkDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder createPlacemarkAlert = new AlertDialog.Builder(getActivity(), R.style.StyledDialog);

    createPlacemarkAlert.setTitle(R.string.dlg_add_placemark);
    createPlacemarkAlert.setIcon(R.mipmap.ic_add_location_white_24dp);

    LayoutInflater inflater = getActivity().getLayoutInflater();
    final View view = (View) inflater.inflate(R.layout.fragment_placemark_dialog, null);

    DescEditText = (EditText) view.findViewById(R.id.placemark_description);
    DescEditText.postDelayed(new Runnable() {
        public void run() {
            if (isAdded()) {
                DescEditText.requestFocus();
                InputMethodManager mgr = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                mgr.showSoftInput(DescEditText, InputMethodManager.SHOW_IMPLICIT);
            }// ww  w  .j  av a 2  s .c  o m
        }
    }, 200);

    createPlacemarkAlert.setView(view)

            //.setPositiveButton(R.string.conti_nue, new DialogInterface.OnClickListener() {
            .setPositiveButton(R.string.dlg_button_add, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    if (isAdded()) {
                        String PlacemarkDescription = DescEditText.getText().toString();
                        final GPSApplication GlobalVariables = (GPSApplication) getActivity()
                                .getApplicationContext();
                        GlobalVariables.setPlacemarkDescription(PlacemarkDescription.trim());
                        EventBus.getDefault().post(EventBusMSG.ADD_PLACEMARK);
                        //Log.w("myApp", "[#] FragmentPlacemarkDialog.java - posted ADD_PLACEMARK: " + PlacemarkDescription);
                    }
                }
            })
            //.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
            .setNegativeButton(R.string.dlg_button_cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {

                }
            });
    return createPlacemarkAlert.create();
}

From source file:org.openmidaas.app.activities.ScanFragment.java

private void showNoQRCodeScannersPresentDialog() {
    AlertDialog.Builder dlBuilder = new AlertDialog.Builder(getActivity());
    dlBuilder.setTitle(R.string.no_qrcode_dialog_title);
    dlBuilder.setMessage(R.string.no_qrcode_dialog_message);
    dlBuilder.setIcon(android.R.drawable.ic_dialog_alert);
    dlBuilder.setPositiveButton(R.string.install_button, new DialogInterface.OnClickListener() {
        @Override//from  w  w w .j  ava2  s  .c  o  m
        public void onClick(DialogInterface dialog, int whichButton) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.ZXING_MARKET));
            AlertDialog aDialog = (AlertDialog) dialog;
            try {

                aDialog.getContext().startActivity(intent);
            } catch (ActivityNotFoundException e) {
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.ZXING_DIRECT));
                aDialog.getContext().startActivity(intent);
            }
        }
    });
    dlBuilder.setNegativeButton(R.string.cancel, null);
    dlBuilder.show();
}

From source file:co.carlosandresjimenez.android.gotit.FollowFragment.java

public void openResultDialog(String message) {

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

    alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
    alertDialogBuilder.setTitle("Request error");

    // set dialog message
    alertDialogBuilder.setMessage(message).setCancelable(false)
            .setPositiveButton(R.string.action_edit, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, close current activity
                    dialog.cancel();/*from  ww  w  .  j a  va 2s .  com*/
                }
            }).setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // if this button is clicked, just close the dialog box and do nothing
                    dialog.cancel();
                    FollowFragment.this.getDialog().dismiss();
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.setCanceledOnTouchOutside(false);

    // show it
    alertDialog.show();

}

From source file:dev.drsoran.moloko.fragments.dialogs.AlertDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (savedInstanceState != null)
        configure(savedInstanceState);/*from  ww w .j  a  v a  2  s .  c  om*/

    final Context context = getSherlockActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context);

    if (iconId != -1)
        builder.setIcon(iconId);

    if (!TextUtils.isEmpty(title))
        builder.setTitle(title);

    if (!TextUtils.isEmpty(message))
        builder.setMessage(message);

    if (positiveButtonTextId != -1)
        builder.setPositiveButton(positiveButtonTextId, getGenericOnClickListener());

    if (negativeButtonTextId != -1)
        builder.setNegativeButton(negativeButtonTextId, getGenericOnClickListener());

    if (neutralButtonTextId != -1)
        builder.setNeutralButton(neutralButtonTextId, getGenericOnClickListener());

    return builder.create();
}

From source file:com.chaitu.lmscalendar.ui.UrlDialog.java

@Override
@NonNull/*w w  w  .  j  a v  a2  s .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mActivity = (MainActivity) getActivity();

    ViewGroup nullViewGroup = null; // Avoid bad lint warning in inflate()
    View view = mActivity.getLayoutInflater().inflate(R.layout.urldialog, nullViewGroup);

    mTextCalendarUrl = (EditText) view.findViewById(R.id.TextCalendarUrl);
    mTextUsername = (EditText) view.findViewById(R.id.TextUsername);
    mTextPassword = (EditText) view.findViewById(R.id.TextPassword);

    Settings settings = mActivity.getSettings();
    mTextCalendarUrl.setText(settings.getString(Settings.PREF_LASTURL));
    mTextUsername.setText(settings.getString(Settings.PREF_LASTURLUSERNAME));
    mTextPassword.setText(settings.getString(Settings.PREF_LASTURLPASSWORD));

    mTextCalendarUrl.selectAll();

    //sync intervals
    mSpinnerSyncInterval = (Spinner) view.findViewById(R.id.sync_interval);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mActivity.getApplicationContext(),
            R.array.sync_intervals, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    mSpinnerSyncInterval.setAdapter(adapter);

    mSpinnerCalendar = (Spinner) view.findViewById(R.id.calendar);
    //calendar
    List<CalendarModel> calendars = EventUtil.readCalendars(mActivity.getApplicationContext(),
            mActivity.getApplicationContext().getContentResolver());

    ArrayAdapter<CalendarModel> adapter1 = new ArrayAdapter<CalendarModel>(mActivity.getApplicationContext(),
            android.R.layout.simple_spinner_dropdown_item, calendars);
    mSpinnerCalendar.setAdapter(adapter1);

    String name = settings.getString(Settings.PREF_LASTCALENDARNAME);
    int id = settings.getInt(Settings.PREF_LASTCALENDARID);
    if (id > 0 && name != null && !name.isEmpty()) {
        CalendarModel cal = new CalendarModel(id, name);
        mSpinnerCalendar.setSelection(adapter1.getPosition(cal));
    }

    DialogInterface.OnClickListener okTask;
    okTask = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface iface, int id) {
            // We override this in onStart()
        }
    };

    DialogInterface.OnClickListener cancelTask;
    cancelTask = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface iface, int id) {
            iface.cancel();
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    AlertDialog dlg = builder.setIcon(R.mipmap.ic_launcher).setTitle(R.string.enter_source_url).setView(view)
            .setPositiveButton(android.R.string.ok, okTask)
            .setNegativeButton(android.R.string.cancel, cancelTask).create();
    dlg.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    return dlg;
}

From source file:org.da_cha.android.bluegnss.MainActivity.java

private void displayAboutDialog() {
    View messageView = getLayoutInflater().inflate(R.layout.about, null, false);
    // we need this to enable html links
    TextView textView = (TextView) messageView.findViewById(R.id.about_license);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    // When linking text, force to always use default color. This works
    // around a pressed color state bug.
    int defaultColor = textView.getTextColors().getDefaultColor();
    textView.setTextColor(defaultColor);
    textView = (TextView) messageView.findViewById(R.id.about_sources);
    textView.setTextColor(defaultColor);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.about_title);
    builder.setIcon(R.drawable.gplv3_icon);
    builder.setView(messageView);/* w  w w .  j a va 2s  .co m*/
    builder.show();
}

From source file:org.birthdayadapter.ui.InstallWorkaroundDialogFragment.java

/**
 * Creates dialog//from w w w . ja v  a  2 s. c  o m
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Linkify the message
    final SpannableString message = new SpannableString(getString(R.string.workaround_dialog_message));
    Linkify.addLinks(message, Linkify.ALL);

    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setTitle(R.string.workaround_dialog_title);
    alert.setMessage(message);
    alert.setCancelable(true);
    alert.setIcon(android.R.drawable.ic_dialog_info);

    alert.setNegativeButton(R.string.workaround_dialog_close_button, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dismiss();
        }
    });
    alert.setNeutralButton(R.string.workaround_dialog_dont_show_again_button, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            PreferencesHelper.setShowWorkaroundDialog(getActivity(), false);
            dismiss();
        }
    });
    alert.setPositiveButton(R.string.workaround_dialog_install_button, new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String workaroundName = "org.birthdayadapter.jb.workaround";
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + workaroundName)));
            } catch (ActivityNotFoundException anfe) {
                // No Google Play installed? Weird! Try with browser!
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + workaroundName)));
            }
        }
    });
    return alert.create();
}