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:bluetoothchat.BluetoothChatFragment.java

/**
 * Function to display simple Alert Dialog
 * @param title - alert dialog title//from  ww  w. j  a v a  2s .  c om
 * @param message - alert message
 * @param status - success/failure (used to set icon)
 * */
public void showAlertDialog(String title, String message, Boolean status) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setPositiveButton("OK", null);
    // Setting Dialog Message
    builder.setMessage(message);
    // Setting alert dialog icon
    builder.setIcon((status) ? R.drawable.success : R.drawable.fail);

    builder.show();
}

From source file:com.songcode.materialnotes.ui.NotesListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (mFocusNoteDataItem == null) {
        Log.e(TAG, "The long click data item is null");
        return false;
    }/*from  w w w  . ja  v a 2s  .co  m*/
    switch (item.getItemId()) {
    case MENU_FOLDER_VIEW:
        openFolder(mFocusNoteDataItem);
        break;
    case MENU_FOLDER_DELETE:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.alert_title_delete));
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setMessage(getString(R.string.alert_message_delete_folder));
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                deleteFolder(mFocusNoteDataItem.getId());
            }
        });
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.show();
        break;
    case MENU_FOLDER_CHANGE_NAME:
        showCreateOrModifyFolderDialog(false);
        break;
    default:
        break;
    }

    return true;
}

From source file:es.farfuteam.vncpp.controller.ActivityTabs.java

/**
 * @return The new dialog/* www . j a  v  a 2s .c o  m*/
 * @brief Shows the dialog with the exit question
 * @details Shows the dialog with the exit question
 */
private Dialog createExitDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    View checkBoxOut = View.inflate(this, R.layout.checkbox_out, null);
    final CheckBox checkBox = (CheckBox) checkBoxOut.findViewById(R.id.checkboxOut);

    final String decision = getString(R.string.RememberCheckBox);

    checkBox.setText(decision);

    final String titleExit = getString(R.string.DialogTitleExit);
    final String question = getString(R.string.DialogQuestion);
    final Activity actThis = this;
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setTitle(titleExit);
    builder.setMessage(question);
    builder.setView(checkBoxOut);
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            actThis.removeDialog(InfoDialogs.exitDialog.ordinal());

        }
    });
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {//un listener que al pulsar, cierre la aplicacion
        @Override
        public void onClick(DialogInterface dialog, int which) {
            //Salir
            (Configuration.getInstance()).setRememberExit(checkBox.isChecked());
            finish();
        }
    });
    return builder.create();
}

From source file:com.andybotting.tramhunter.activity.HomeActivity.java

/**
 * Show the about dialog//from ww w. j  a v  a2 s  .  c  o  m
 */
public void showAbout() {
    // Get the package name
    String heading = getResources().getText(R.string.app_name).toString();

    try {
        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        heading += " v" + pi.versionName + "";
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    // Build alert dialog, using a ContextThemeWrapper for proper theming
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(
            new ContextThemeWrapper(this, R.style.AlertDialog));
    View aboutView = View.inflate(new ContextThemeWrapper(this, R.style.AlertDialog), R.layout.dialog_about,
            null);
    dialogBuilder.setTitle(heading);
    dialogBuilder.setView(aboutView);
    dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            mPreferenceHelper.setFirstLaunchThisVersion();
        }
    });
    dialogBuilder.setCancelable(false);
    dialogBuilder.setIcon(R.drawable.icon);
    dialogBuilder.show();
}

From source file:at.wada811.android.dialogfragments.AlertDialogFragment.java

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

    final Bundle args = getArguments();
    final int theme = args.getInt(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);
    }

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

    final CharSequence title = args.getCharSequence(TITLE);
    boolean useCustomTitle = args.getBoolean(CUSTOM_TITLE);
    if (title != null) {
        builder.setTitle(title);
    } else if (useCustomTitle) {
        setCustomTitle(builder);
    }

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

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

    // View
    setView(builder);

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

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

    // Build
    return builder.create();
}

From source file:com.doomonafireball.hackerswiperfree.android.activity.MainActivity.java

private void showOpenSourceDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.open_source_licenses);
    String[] apacheProjects = getResources().getStringArray(R.array.apache_licensed_projects);
    StringBuilder sb = new StringBuilder();
    sb.append(getResources().getString(R.string.licenses_header));
    for (String project : apacheProjects) {
        sb.append("\u2022 ").append(project).append("\n");
    }/*from   ww w .ja v a  2 s.  com*/
    sb.append("\n").append(getResources().getString(R.string.licenses_subheader));
    sb.append(getResources().getString(R.string.apache_2_0_license));
    builder.setMessage(sb.toString());
    builder.setPositiveButton(getString(R.string.close), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.setCancelable(true);
    builder.setIcon(android.R.drawable.ic_menu_info_details);
    AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.UpdatePasswordDialog.java

public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    rootView = inflater.inflate(R.layout.dialog_update_passwords, null);

    visibility = false;//from w  w w  .  ja  va2s  .c  o  m

    spinnerOld = (ProgressBar) rootView.findViewById(R.id.oldProgressBar);
    spinnerOld.setVisibility(View.GONE);

    spinnerNew = (ProgressBar) rootView.findViewById(R.id.newProgressBar);
    spinnerNew.setVisibility(View.GONE);

    Bundle bundle = getArguments();

    position = bundle.getInt("position");
    bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled");
    hashAlgorithm = bundle.getString("hash_algorithm");
    setOldMetaData(bundle);
    number_iterations = bundle.getInt("number_iterations");

    database = MetaDataSQLiteHelper.getInstance(getActivity());

    builder.setView(rootView);

    builder.setIcon(R.mipmap.ic_drawer);

    builder.setTitle(getActivity().getString(R.string.passwords_heading));

    Button displayButton = (Button) rootView.findViewById(R.id.displayButton);
    displayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(view.getWindowToken(),
                    InputMethodManager.RESULT_UNCHANGED_SHOWN);

            displayPasswords();
        }
    });

    ImageButton copyOldButton = (ImageButton) rootView.findViewById(R.id.copyOldButton);
    ImageButton copyNewButton = (ImageButton) rootView.findViewById(R.id.copyNewButton);

    copyOldButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView oldPassword = (TextView) rootView.findViewById(R.id.textViewOldPassword);
            ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("", oldPassword.getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_old),
                    Toast.LENGTH_SHORT).show();
        }
    });

    copyNewButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView newPassword = (TextView) rootView.findViewById(R.id.textViewNewPassword);
            ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("", newPassword.getText());
            clipboard.setPrimaryClip(clip);
            Toast.makeText(getActivity(), getActivity().getString(R.string.copy_clipboar_new),
                    Toast.LENGTH_SHORT).show();
        }
    });

    builder.setPositiveButton(getActivity().getString(R.string.done), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            onClickDone();
        }
    });

    visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton);

    visibilityButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            editTextUpdateMasterpassword = (EditText) rootView.findViewById(R.id.editTextUpdateMasterpassword);

            if (!visibility) {
                visibilityButton.setImageResource(R.drawable.ic_visibility_off);
                editTextUpdateMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length());
                visibility = true;
            } else {
                visibilityButton.setImageResource(R.drawable.ic_visibility);
                editTextUpdateMasterpassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                editTextUpdateMasterpassword.setSelection(editTextUpdateMasterpassword.getText().length());
                visibility = false;
            }
        }
    });

    return builder.create();
}

From source file:com.pdmanager.views.patient.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    if (id == R.id.action_technician) {

        AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
        alertDialog.setTitle("PASSWORD");
        alertDialog.setMessage("Enter Password");

        final EditText input = new EditText(MainActivity.this);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        input.setLayoutParams(lp);//from  ww  w .j  a v  a  2s.  c  o m
        alertDialog.setView(input);
        alertDialog.setIcon(R.drawable.pdmanager);

        alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String pass = "pdmanager";
                String password = input.getText().toString();
                if (password.compareTo("") != 0) {
                    if (pass.equals(password)) {
                        Toast.makeText(getApplicationContext(), "Password Matched", Toast.LENGTH_SHORT).show();

                        Intent mainIntent = new Intent(MainActivity.this, TechnicianActivity.class);
                        MainActivity.this.startActivity(mainIntent);
                        finish();

                    } else {
                        Toast.makeText(getApplicationContext(), "Wrong Password!", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });

        alertDialog.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });

        alertDialog.show();
    } else if (id == R.id.action_termsandconditions) {

        Intent mainIntent = new Intent(MainActivity.this, TermsAndConds.class);
        MainActivity.this.startActivity(mainIntent);
        //  finish();

    }

    return super.onOptionsItemSelected(item);
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (this.currentGameIndex == this.getGameSet().getGameCount()) {
        MenuItem miTrash = menu.add(this.getString(R.string.lblDeleteGameItem));
        miTrash.setIcon(R.drawable.gd_action_bar_trashcan);
        miTrash.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
        miTrash.setOnMenuItemClickListener(new OnMenuItemClickListener() {

            /* (non-Javadoc)
             * @see com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener#onMenuItemClick(com.actionbarsherlock.view.MenuItem)
             *///w w w  .  j a  v a  2 s .com
            @Override
            public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) {
                AlertDialog.Builder builder = new AlertDialog.Builder(GameReadViewPagerActivity.this);
                String dialogTitle = String.format(
                        GameReadViewPagerActivity.this.getString(R.string.titleRemoveGameYesNo),
                        GameReadViewPagerActivity.this.currentGameIndex);
                String dialogMessage = GameReadViewPagerActivity.this.getString(R.string.msgRemoveGameYesNo);
                builder.setTitle(dialogTitle);
                builder.setMessage(dialogMessage);
                builder.setPositiveButton(GameReadViewPagerActivity.this.getString(R.string.btnOk),
                        GameReadViewPagerActivity.this.removeGameDialogClickListener);
                builder.setNegativeButton(GameReadViewPagerActivity.this.getString(R.string.btnCancel),
                        GameReadViewPagerActivity.this.removeGameDialogClickListener);
                builder.show();
                builder.setIcon(android.R.drawable.ic_dialog_alert);
                return true;
            }
        });
    }
    return true;
}

From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java

private void failDialog(int i) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    if (i == 2 || i == 3) {
        alertDialog.setTitle("  ? ");
        alertDialog.setMessage("? ? ");
    } else if (i == 1) {
        alertDialog.setTitle("   ");
        alertDialog.setMessage(" ? ");
    } else if (i == 4) {
        alertDialog.setTitle("  ");
        alertDialog.setMessage(" ? ");
    }/*from  w w w. j  a  va  2 s  .  co m*/

    alertDialog.setIcon(R.drawable.fail);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to invoke YES event
            dialog.cancel();
        }
    });

    alertDialog.show();
}