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:org.steveleach.scoresheet.ui.ScoresheetActivity.java

private void showAbout() {
    // Inflate the about message contents
    View messageView = getLayoutInflater().inflate(R.layout.about, null, false);

    TextView version = (TextView) messageView.findViewById(R.id.txtAppVersion);
    String versionText = getApplicationContext().getString(R.string.appVersionText,
            context.applicationVersion());
    version.setText(versionText);//  www . j  ava2 s  .co m

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.mipmap.ic_launcher);
    builder.setTitle(R.string.app_name);
    builder.setView(messageView);
    builder.create();
    builder.show();
}

From source file:com.xargsgrep.portknocker.activity.EditHostActivity.java

private void showCancelDialog() {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle(R.string.confirm_dialog_cancel_edit_title);
    dialogBuilder.setIcon(R.drawable.ic_dialog_confirm);

    dialogBuilder.setPositiveButton(R.string.confirm_dialog_confirm, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            returnToHostListActivity(null);
        }/*w ww.java2  s .  co m*/
    });
    dialogBuilder.setNegativeButton(R.string.confirm_dialog_cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    cancelDialog = dialogBuilder.create();
    cancelDialog.show();
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    rootView = inflater.inflate(R.layout.dialog_add_metadata, null);

    versionVisible = false;//w w w  .  ja v  a 2  s . c  om

    builder.setView(rootView);
    builder.setIcon(R.mipmap.ic_drawer);
    builder.setTitle(getActivity().getString(R.string.add_metadata_heading));

    database = MetaDataSQLiteHelper.getInstance(getActivity());

    //Seekbar
    SeekBar seekBarLength = (SeekBar) rootView.findViewById(R.id.seekBarLength);
    final TextView textViewLengthDisplayFinal = (TextView) rootView.findViewById(R.id.textViewLengthDisplay);
    seekBarLength.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            textViewLengthDisplayFinal.setText(Integer.toString(progress + 4));
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    });

    ImageButton versionInfoImageButton = (ImageButton) rootView.findViewById(R.id.versionInfoImageButton);
    versionInfoImageButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder infoBbuilder = new AlertDialog.Builder(getActivity());
            infoBbuilder.setTitle(getString(R.string.dialog_version_title));
            infoBbuilder.setMessage(R.string.dialog_version);
            infoBbuilder.show();
        }

    });

    Button versionButton = (Button) rootView.findViewById(R.id.versionButton);
    versionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LinearLayout versionDataLayout = (LinearLayout) rootView.findViewById(R.id.versionDataLayout);
            TextView versionTextView = (TextView) rootView.findViewById(R.id.versionButton);
            if (!versionVisible) {
                versionDataLayout.setVisibility(View.VISIBLE);
                versionTextView.setText(getString(R.string.change_version_opened));
                versionTextView.setTextColor(Color.BLACK);
                versionVisible = true;
            } else {
                versionDataLayout.setVisibility(View.GONE);
                versionTextView.setText(getString(R.string.change_version_closed));
                versionTextView.setTextColor(Color.parseColor("#d3d3d3"));
                versionVisible = false;
            }

        }

    });

    EditText iterations = (EditText) rootView.findViewById(R.id.EditTextIteration);
    iterations.setText("1");

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

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

            addMetaData();

        }
    });

    builder.setNegativeButton(getActivity().getString(R.string.cancel), null);

    return builder.create();
}

From source file:edu.neu.madcourse.kevinpacheco.butterflycatcher.MainActivity.java

private void onProviderDisabled(String provider) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("GPS is disabled");
    builder.setMessage("Note: GPS must be enabled in order to play.");
    builder.setIcon(R.drawable.butterfly_dialog);
    builder.setCancelable(false);//  ww  w .j a v a  2  s.  c om
    builder.setPositiveButton("Enable GPS", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent startGps = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            startActivity(startGps);
        }
    });

    builder.setNegativeButton("Back", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            finish();
        }
    });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:eu.vranckaert.worktime.utils.donations.DonationsFragment.java

private void displayDialog(int id) {
    int icon = -1;
    int title = -1;
    int message = -1;

    switch (id) {
    case DIALOG_BILLING_NOT_SUPPORTED_ID:
        icon = android.R.drawable.ic_dialog_alert;
        title = R.string.donations__google_android_market_not_supported_title;
        message = R.string.donations__google_android_market_not_supported;
    case DIALOG_THANKS:
        icon = android.R.drawable.ic_dialog_info;
        title = R.string.donations__thanks_dialog_title;
        message = R.string.donations__thanks_dialog;
    default:/*from   w w w.j a v a  2s . c om*/
    }

    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:br.com.GUI.avaliacoes.NovaAvaliacao.java

@Override
public void onBackPressed() {

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("Ateno");
    alertDialog.setMessage(/*from   w  w w .  j a va 2s  .  c o m*/
            "Voc tem certeza que deseja sair desta avaliao?\n Todos os dados que no foram salvos sero perdidos!");
    alertDialog.setIcon(R.drawable.critical);
    alertDialog.setPositiveButton("Sim", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            editor.clear();
            editor.commit();
            finish();
        }
    });
    alertDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alertDialog.show();

}

From source file:com.giltesa.taskcalendar.activity.Main.java

/**
 * Se capturan todas las pulsaciones de las teclas fsicas del dispositivo para poder personalizar los eventos que lanzan.
 *//*from  w  w w.ja  v a  2 s  . c  o  m*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    //Si la tecla pulsada es la de Atrs, y el usuario ha configurado la solicitud de confirmacin. Se pide dicha solicitud:
    if (keyCode == KeyEvent.KEYCODE_BACK && prefs.isConfirmExit()) {
        // Se muestra el mensaje por pantalla:
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setIcon(android.R.drawable.ic_dialog_alert);
        alert.setTitle(getResources().getString(R.string.main_exit_title));
        alert.setMessage(getResources().getString(R.string.main_exit_summary));
        alert.setNegativeButton(android.R.string.cancel, null);
        alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        alert.show();
        // Como se ha tratado el evento de la tecla atrs, se devuelve true.
        return true;
    }
    // Si aqu no se ha tratado el evento se le enva al padre para que lo trate l.
    return super.onKeyDown(keyCode, event);
}

From source file:com.yeldi.yeldibazaar.ManageRepo.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {

    super.onMenuItemSelected(featureId, item);
    LayoutInflater li = LayoutInflater.from(this);

    switch (item.getItemId()) {
    case ADD_REPO:
        View view = li.inflate(R.layout.addrepo, null);
        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();

        alrt.setIcon(android.R.drawable.ic_menu_add);
        alrt.setTitle(getString(R.string.repo_add_title));
        alrt.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.repo_add_add),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        EditText uri = (EditText) alrt.findViewById(R.id.edit_uri);
                        String uri_str = uri.getText().toString();
                        try {
                            DB db = DB.getDB();
                            db.addRepo(uri_str, null, null, 10, null, true);
                        } finally {
                            DB.releaseDB();
                        }/*  ww w.  j  ava2  s. com*/
                        changed = true;
                        redraw();
                    }
                });

        alrt.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
        alrt.show();
        return true;

    case REM_REPO:
        final List<String> rem_lst = new ArrayList<String>();
        CharSequence[] b = new CharSequence[repos.size()];
        for (int i = 0; i < repos.size(); i++) {
            b[i] = repos.get(i).address;
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getString(R.string.repo_delete_title));
        builder.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
        builder.setMultiChoiceItems(b, null, new DialogInterface.OnMultiChoiceClickListener() {
            public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) {
                if (isChecked) {
                    rem_lst.add(repos.get(whichButton).address);
                } else {
                    rem_lst.remove(repos.get(whichButton).address);
                }
            }
        });
        builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                try {
                    DB db = DB.getDB();
                    removeRepos(rem_lst);
                } finally {
                    DB.releaseDB();
                }
                changed = true;
                redraw();
            }
        });
        builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                return;
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    }
    return true;
}

From source file:com.restswitch.controlpanel.MainActivity.java

private void alertError(String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Error");
    builder.setMessage(msg);//from   w ww. j  ava 2 s.  com
    builder.setNeutralButton("OK", null);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.show();
}

From source file:br.com.GUI.perfil.MeuPersonal.java

public void adicionarRemoverMeuPersonal() {

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle("Confirme esta ao");
    alertDialog.setMessage("Voc realmente deseja remover seu treinador?");
    alertDialog.setIcon(R.drawable.profile);
    alertDialog.setNegativeButton("Sim", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (a.getUsuarioPersonal().equals(p.getUsuario())) {

                if (a.removerAlunoWeb(a.getUsuario()) && a.removerAluno(b)) {
                    Toast.makeText(getActivity(), "Removido com Sucesso", Toast.LENGTH_SHORT).show();

                    // Exclui todas as aulas marcadas com o personal
                    ArrayList<Aula> aulasParaExcluir = new ArrayList<Aula>();

                    aulasParaExcluir = new Aula().buscarAulasPorAlunoWeb(a.getUsuario(), "");
                    for (Aula c : aulasParaExcluir) {
                        if (c.excluirAulaWeb() && c.excluirAula(b)) {
                            Log.i("INFORMAO", "Aulas excluidas com sucesso!");
                        }//from   www  .  ja  v a 2 s  .com
                    }

                    atualizarMeuPersonal();
                } else {
                    Toast.makeText(getActivity(), "Falha ao Remover o aluno", Toast.LENGTH_SHORT).show();
                }
            }
            atualizarMeuPersonal();
        }
    });
    alertDialog.setPositiveButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    // Showing Alert Message
    alertDialog.show();

}