List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:goo.TeaTimer.TimerActivity.java
/** {@inheritDoc} */ @Override/*from w w w. java 2 s. co m*/ protected Dialog onCreateDialog(int id) { Dialog d = null; switch (id) { case NUM_PICKER_DIALOG: { int[] timeVec = TimerUtils.time2Mhs(mLastTime); int[] init = { timeVec[0], timeVec[1], timeVec[2] }; int[] inc = { 1, 1, 1 }; int[] start = { 0, 0, 0 }; int[] end = { 23, 59, 59 }; String[] sep = { ":", ".", "" }; NumberPicker.Formatter[] format = { NumberPicker.TWO_DIGIT_FORMATTER, NumberPicker.TWO_DIGIT_FORMATTER, NumberPicker.TWO_DIGIT_FORMATTER }; d = new NNumberPickerDialog(this, this, getResources().getString(R.string.InputTitle), init, inc, start, end, sep, format); } break; case ALERT_DIALOG: { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getResources().getText(R.string.warning_text)).setCancelable(false) .setPositiveButton(getResources().getText(R.string.warning_button), null) .setTitle(getResources().getText(R.string.warning_title)); d = builder.create(); } break; } return d; }
From source file:se.anyro.nfc_reader.TagViewer.java
private void showWirelessSettingsDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.nfc_disabled); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS); startActivity(intent);//w w w. j av a 2 s.c o m } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); builder.create().show(); return; }
From source file:com.otaupdater.SettingsActivity.java
@Override @SuppressWarnings("deprecation") public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == accountPref) { showAccountDialog();/*from ww w.j a v a 2 s .com*/ } else if (preference == notifPref) { cfg.setShowNotif(notifPref.isChecked()); } else if (preference == wifidlPref) { cfg.setWifiOnlyDl(wifidlPref.isChecked()); } else if (preference == autodlPref) { if (cfg.hasProKey()) { cfg.setAutoDlState(autodlPref.isChecked()); } else { Utils.showProKeyOnlyFeatureDialog(this, this); cfg.setAutoDlState(false); autodlPref.setChecked(false); } } else if (preference == resetWarnPref) { cfg.clearIgnored(); } else if (preference == prokeyPref) { if (cfg.hasProKey()) { AlertDialog.Builder builder = new AlertDialog.Builder(this); if (cfg.isKeyRedeemCode()) { builder.setMessage(R.string.prokey_redeemed_thanks); } else { builder.setMessage(R.string.prokey_thanks); } builder.setNeutralButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); } else { showGetProKeyDialog(); } } else if (preference == donatePref) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL))); } else { return super.onPreferenceTreeClick(preferenceScreen, preference); } return true; }
From source file:com.mocap.MocapFragment.java
void alert(String message) { AlertDialog.Builder bld = new AlertDialog.Builder(getActivity()); bld.setMessage(message);/*from w w w. j av a 2s. c om*/ bld.setNeutralButton("OK", null); Log.i(TAG2, "Showing alert dialog: " + message); bld.create().show(); }
From source file:com.rei.lolchat.ui.Login.java
/** * Create an about "BEEM" dialog./*w w w .j a v a 2 s . c o m*/ */ private void createAboutDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String versionname; try { PackageManager pm = getPackageManager(); PackageInfo pi = pm.getPackageInfo("com.rei.lolchat", 0); versionname = pi.versionName; } catch (PackageManager.NameNotFoundException e) { versionname = ""; } String title = getString(R.string.login_about_title, versionname); builder.setTitle(title).setMessage(R.string.login_about_msg).setCancelable(false); builder.setNeutralButton(R.string.login_about_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); AlertDialog aboutDialog = builder.create(); aboutDialog.show(); }
From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java
private Dialog onCreateSelectAccountDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.select_account); final CharSequence[] items = new CharSequence[mAccounts.length]; int i = 0;/*from w ww .j a va2 s . co m*/ for (Account a : mAccounts) { items[i++] = a.name; } builder.setItems(items, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mAccount = mAccounts[which]; showDialog(DIALOG_PASSWD); } }); builder.setCancelable(false); return builder.create(); }
From source file:net.eledge.android.europeana.gui.dialog.NameInputDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.dialog_nameinput, null); TextView text = (TextView) view.findViewById(R.id.dialog_nameinput_textview); if (resText != -1) { text.setText(resText);/*from w ww.j ava 2s.c om*/ } else { text.setVisibility(View.GONE); } mInput = (EditText) view.findViewById(R.id.dialog_nameinput_edittext); mInput.setHint(resInput); mInput.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { //ignore } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //ignore } @Override public void afterTextChanged(Editable s) { mDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(StringUtils.isNotBlank(s.toString())); } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(view); if (resTitle != -1) { builder.setTitle(resTitle); } builder.setPositiveButton(resPositiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { String input = mInput.getText().toString(); if (StringUtils.isNotBlank(input)) { mListener.positiveResponse(input); NameInputDialog.this.dismiss(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { mListener.negativeResponse(); mDialog.dismiss(); } }); mDialog = builder.create(); mDialog.setCanceledOnTouchOutside(false); mDialog.setCancelable(false); return mDialog; }
From source file:com.webileapps.fragments.CordovaFragment.java
/** * Display an error dialog and optionally exit application. *///from w ww . j ava2 s .c o m public void displayError(final String title, final String message, final String button, final boolean exit) { final CordovaFragment me = this; me.getActivity().runOnUiThread(new Runnable() { public void run() { try { AlertDialog.Builder dlg = new AlertDialog.Builder(me.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setPositiveButton(button, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (exit) { getActivity().finish(); } } }); dlg.create(); dlg.show(); } catch (Exception e) { getActivity().finish(); } } }); }
From source file:com.spoiledmilk.cykelsuperstier.break_rote.BreakRouteActivity.java
private void showRouteNoBreakDialog() { if (dialog == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(CykelsuperstierApplication.getString("no_route")); builder.setMessage(CykelsuperstierApplication.getString("cannot_broken")); builder.setPositiveButton("OK", new OnClickListener() { @Override/* ww w. j a va2 s . co m*/ public void onClick(DialogInterface dialog, int arg1) { dialog.dismiss(); finish(); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } }); dialog = builder.create(); dialog.setCancelable(false); } dialog.show(); }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private void showVersionInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")"); builder.setMessage(getVersionInfo(false)); builder.setIcon(R.drawable.ic_launcher); builder.setPositiveButton(getString(android.R.string.copy), new DialogInterface.OnClickListener() { @Override//from w w w . jav a 2s. c o m public void onClick(DialogInterface dialog, int which) { DeprecatedUtils.setClipboard(getBaseContext(), getVersionInfo(true)); } }); builder.create().show(); }