List of usage examples for android.app AlertDialog setIcon
public void setIcon(Drawable icon)
From source file:com.glanznig.beepme.view.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { BeeperApp app = (BeeperApp) getApplication(); switch (item.getItemId()) { case R.id.action_toggle_beeper: if (app.isBeeperActive()) { app.cancelTimer(); //call before setBeeperActive app.setBeeperActive(BeeperApp.BEEPER_INACTIVE); item.setIcon(R.drawable.ic_menu_beeper_off); // hide generate beep menu entry if (this.actionMenu != null && app.getPreferences().isTestMode()) { MenuItem testBeep = actionMenu.findItem(R.id.action_test_beep); testBeep.setVisible(false); }// w ww .ja v a2 s . c o m } else { app.setBeeperActive(BeeperApp.BEEPER_ACTIVE); app.setTimer(); item.setIcon(R.drawable.ic_menu_beeper_on); // show generate beep menu entry if (this.actionMenu != null && app.getPreferences().isTestMode()) { MenuItem testBeep = actionMenu.findItem(R.id.action_test_beep); testBeep.setVisible(true); } } return true; case R.id.action_test_beep: app.beep(); return true; case R.id.action_export: Intent iExport = new Intent(this, ExportActivity.class); startActivity(iExport); return true; case R.id.action_settings: Intent iSettings = new Intent(this, SettingsActivity.class); startActivity(iSettings); return true; case R.id.action_about: // thanks to F-Droid for the inspiration View view = null; LayoutInflater inflater = LayoutInflater.from(this); view = inflater.inflate(R.layout.about, null); try { PackageInfo pkgInfo = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0); ((TextView) view.findViewById(R.id.about_version)).setText(pkgInfo.versionName); } catch (Exception e) { } AlertDialog.Builder alertBuilder = null; alertBuilder = new AlertDialog.Builder(this).setView(view); AlertDialog dia = alertBuilder.create(); dia.setIcon(R.drawable.ic_launcher_beepme); dia.setTitle(getString(R.string.about_title)); dia.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_donate_button), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Uri uri = Uri.parse("http://beepme.yourexp.at/support-beepme"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); dia.setButton(AlertDialog.BUTTON_NEGATIVE, getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { } }); dia.show(); return true; } return super.onOptionsItemSelected(item); }
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(); }/*from w ww. jav a 2 s . c o m*/ 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.veniosg.dir.android.dialog.SingleDeleteDialog.java
@NonNull @Override// w w w . ja v a 2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { FileHolder holder = getArguments().getParcelable(EXTRA_DIALOG_FILE_HOLDER); if (holder != null) { AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(getString(R.string.really_delete, holder.getName())) .setPositiveButton(R.string.yes, (dialog1, which) -> { new DeleteAsyncTask(getContext()).execute(holder); }).setNegativeButton(R.string.no, null).create(); dialog.setIcon(R.drawable.ic_dialog_delete); return dialog; } else { dismiss(); return new Dialog(getContext()); } }
From source file:com.veniosg.dir.android.dialog.RenameDialog.java
@NonNull @Override// w ww. j av a 2 s . c om public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null); final EditText v = view.findViewById(R.id.textinput); v.setText(mFileHolder.getName()); v.setOnEditorActionListener((tv, actionId, event) -> { if (actionId == IME_ACTION_GO) { tryRename(tv.getText().toString()); } return true; }); AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_rename).setView(view) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, (dialog1, which) -> tryRename(v.getText().toString())) .create(); dialog.setIcon(mFileHolder.getIcon()); return dialog; }
From source file:sssemil.com.hostsaway.ui.BlacklistFragment.java
/** * Add new entry based on input/*from ww w .j a v a 2 s.c om*/ * * @param input */ private void addEntry(String input) { if (input != null) { if (RegexUtils.isValidHostname(input)) { ProviderHelper.insertBlacklistItem(mActivity, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }
From source file:sssemil.com.hostsaway.ui.WhitelistFragment.java
/** * Add new entry based on input/* ww w. j ava 2 s. c o m*/ * * @param input */ private void addEntry(String input) { if (input != null) { if (RegexUtils.isValidWhitelistHostname(input)) { ProviderHelper.insertWhitelistItem(mActivity, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }
From source file:com.aikidonord.Intervenant.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_intervenant); View rlLoading = findViewById(R.id.loadingPanel); View listView = findViewById(R.id.list); ActionBar actionBar = this.getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getResources().getString(R.string.actionbar_titre_intervenant)); if (VerifConnexion.isOnline(this)) { rlLoading.setVisibility(View.VISIBLE); listView.setVisibility(View.GONE); new QueryForAnimateurTask().execute(this, this.getApplicationContext()); } else {/* w w w. j av a 2 s. co m*/ AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(getResources().getString(R.string.app_name)); alertDialog.setMessage(getResources().getString(R.string.no_network)); alertDialog.setIcon(R.drawable.ic_launcher); alertDialog.setCancelable(false); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getResources().getString(R.string.close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity Intervenant.this.finish(); } }); alertDialog.show(); } }
From source file:org.adaway.ui.BlacklistFragment.java
/** * Add new entry based on input//from w w w. ja v a 2s. com * * @param input */ private void addEntry(String input) { if (input != null) { if (RegexUtils.isValidHostname(input)) { ProviderHelper.insertBlacklistItem(mActivity, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(org.adaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }
From source file:org.adaway.ui.WhitelistFragment.java
/** * Add new entry based on input//from w w w . j a v a 2 s .c om * * @param input */ private void addEntry(String input) { if (input != null) { if (RegexUtils.isValidWhitelistHostname(input)) { ProviderHelper.insertWhitelistItem(mActivity, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(org.adaway.R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }
From source file:org.adawaycn.ui.WhitelistFragment.java
/** * Add new entry based on input//from w w w. ja v a 2 s .com * * @param input */ private void addEntry(String input) { if (input != null) { if (RegexUtils.isValidWhitelistHostname(input)) { ProviderHelper.insertWhitelistItem(mActivity, input); } else { AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_alert); alertDialog.setTitle(R.string.no_hostname_title); alertDialog.setMessage(getString(R.string.no_hostname)); alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sum) { dlg.dismiss(); } }); alertDialog.show(); } } }