List of usage examples for android.app AlertDialog findViewById
@Nullable public <T extends View> T findViewById(@IdRes int id)
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static boolean showHintWithImage(final Activity activity, final MainService mainService, final SafeRunnable onDismissHandler, final String hintCode, final FontAwesome.Icon hintIcon, final int hintResource, final Object... args) { final ConfigurationProvider configurationProvider = mainService.getConfigurationProvider(); final String configkey = "HINT_REPOSITORY"; final com.mobicage.rogerthat.config.Configuration config = configurationProvider .getConfiguration(configkey); if (config.get(hintCode, false)) return false; LayoutInflater inflater = activity.getLayoutInflater(); final View checkboxLayout = inflater.inflate(R.layout.hint, null); final TextView message = (TextView) checkboxLayout.findViewById(R.id.message); final CheckBox checkBox = (CheckBox) checkboxLayout.findViewById(R.id.checkBox); if (hintIcon != null) { final ImageView icon = (ImageView) checkboxLayout.findViewById(R.id.icon); icon.setImageDrawable(new IconicsDrawable(activity, hintIcon).color(Color.DKGRAY).sizeDp(30)); icon.setVisibility(View.VISIBLE); }/*from w w w . j av a 2s .c o m*/ Resources resources = activity.getResources(); message.setText(resources.getString(hintResource, args)); AlertDialog dialog = new AlertDialog.Builder(activity) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (onDismissHandler != null) { onDismissHandler.run(); } } }).setTitle(R.string.activity_hint).setView(checkboxLayout).setPositiveButton( resources.getString(R.string.activity_close_hint), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (checkBox.isChecked()) { config.put(hintCode, true); configurationProvider.updateConfigurationNow(configkey, config); } if (onDismissHandler != null) { onDismissHandler.run(); } } }) .create(); dialog.show(); int buttonId = mainService.getResources().getIdentifier("android:id/button1", null, null); ((Button) dialog.findViewById(buttonId)).setTextColor(LookAndFeelConstants.getPrimaryColor(activity)); return true; }
From source file:org.eyeseetea.malariacare.LoginActivity.java
/** * Shows an alert dialog asking for acceptance of the EULA terms. If ok calls login function, * do//from w ww . j a v a 2 s .c o m * nothing otherwise */ public void askEula(int titleId, int rawId, final Context context) { InputStream message = context.getResources().openRawResource(rawId); String stringMessage = Utils.convertFromInputStreamToString(message).toString(); final SpannableString linkedMessage = new SpannableString(Html.fromHtml(stringMessage)); Linkify.addLinks(linkedMessage, Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS); AlertDialog dialog = new AlertDialog.Builder(context).setTitle(context.getString(titleId)) .setMessage(linkedMessage) .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { rememberEulaAccepted(context); login(serverText.getText().toString(), usernameEditText.getText().toString(), passwordEditText.getText().toString()); } }).setNegativeButton(android.R.string.no, null).create(); dialog.show(); ((TextView) dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private void prepareExportKeysDialog(final Dialog dialog) { final AlertDialog alertDialog = (AlertDialog) dialog; final EditText passwordView = (EditText) alertDialog.findViewById(R.id.export_keys_dialog_password); passwordView.setText(null);//from w w w. j a va 2s.co m final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener( passwordView, alertDialog); passwordView.addTextChangedListener(dialogButtonEnabler); final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.export_keys_dialog_show); showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView)); KnCDialog.fixDialogDivider(alertDialog); }
From source file:net.fabiszewski.ulogger.MainActivity.java
/** * Display About dialog/*from w ww . j av a 2 s . c o m*/ */ private void showAbout() { @SuppressLint("InflateParams") View view = getLayoutInflater().inflate(R.layout.about, null, false); AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.app_name)); alertDialog.setView(view); alertDialog.setIcon(R.drawable.ic_ulogger_logo_24dp); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); final TextView versionLabel = (TextView) alertDialog.findViewById(R.id.about_version); versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME)); final TextView descriptionLabel = (TextView) alertDialog.findViewById(R.id.about_description); final TextView description2Label = (TextView) alertDialog.findViewById(R.id.about_description2); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { descriptionLabel.setText(fromHtmlDepreciated(getString(R.string.about_description))); description2Label.setText(fromHtmlDepreciated(getString(R.string.about_description2))); } else { descriptionLabel.setText( Html.fromHtml(getString(R.string.about_description), android.text.Html.FROM_HTML_MODE_LEGACY)); description2Label.setText( Html.fromHtml(getString(R.string.about_description2), android.text.Html.FROM_HTML_MODE_LEGACY)); } }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void onRemoveClick(View view) { try {//from w w w. j a v a2 s . co m Toast.makeText(this, item, Toast.LENGTH_SHORT).show(); String[] remove = { "rm", "-rf", irpath + item }; try { Process p = Runtime.getRuntime().exec(remove); Log.i("rm", "Waiting... " + irpath + item); p.waitFor(); Log.i("rm", "Done! " + irpath + item); } catch (Exception e) { Log.e("rm", "Failed! " + irpath + item); e.printStackTrace(); } spinner = ((Spinner) findViewById(R.id.spinner)); localArrayList1 = new ArrayList(); localArrayList1.remove(item); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, localArrayList1); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(dataAdapter); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.done)); builder.setMessage(getString(R.string.done_removing) + " " + item + " " + getString(R.string.files)); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); } catch (NullPointerException ex) { ex.printStackTrace(); AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.error)); adb.setMessage(getString(R.string.you_need_to_select)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb.show(); } }
From source file:net.fabiszewski.ulogger.MainActivity.java
/** * Called when the user clicks the track text view * @param view View/* www.jav a 2 s.c o m*/ */ public void trackSummary(@SuppressWarnings("UnusedParameters") View view) { final TrackSummary summary = db.getTrackSummary(); if (summary == null) { showToast(getString(R.string.no_positions)); return; } @SuppressLint("InflateParams") View summaryView = getLayoutInflater().inflate(R.layout.summary, null, false); AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.track_summary)); alertDialog.setView(summaryView); alertDialog.setIcon(R.drawable.ic_equalizer_white_24dp); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); final TextView summaryDistance = (TextView) alertDialog.findViewById(R.id.summary_distance); final TextView summaryDuration = (TextView) alertDialog.findViewById(R.id.summary_duration); final TextView summaryPositions = (TextView) alertDialog.findViewById(R.id.summary_positions); double distance = (double) summary.getDistance() / 1000; String unitName = getString(R.string.unit_kilometer); if (pref_units.equals(getString(R.string.pref_units_imperial))) { distance *= KM_MILE; unitName = getString(R.string.unit_mile); } final NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); final String distanceString = nf.format(distance); summaryDistance.setText(getString(R.string.summary_distance, distanceString, unitName)); final long h = summary.getDuration() / 3600; final long m = summary.getDuration() % 3600 / 60; summaryDuration.setText(getString(R.string.summary_duration, h, m)); int positionsCount = (int) summary.getPositionsCount(); if (needsPluralFewHack(positionsCount)) { summaryPositions.setText(getResources().getString(R.string.summary_positions_few, positionsCount)); } else { summaryPositions.setText( getResources().getQuantityString(R.plurals.summary_positions, positionsCount, positionsCount)); } }
From source file:com.sssemil.sonyirremote.ir.ir.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { setContentView(R.layout.settings_ir); main = false;/* w w w .j ava2 s . c o m*/ final GetAwItems getAwItems1 = new GetAwItems(ir.this); String ret = getAwItems1.execute().get(); spinner6 = ((Spinner) findViewById(R.id.spinner6)); spinner6.setSelection(0); ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ar); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner6.setAdapter(dataAdapter); prepItemBrandArray(); return true; } else if (id == R.id.action_about) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.about)); PackageInfo pInfo = null; String version = "?"; try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } version = pInfo.versionName; builder.setMessage(getResources().getString(R.string.license1) + " v" + version + "\n" + getResources().getString(R.string.license2) + "\n" + getResources().getString(R.string.license3) + "\n" + getResources().getString(R.string.license4)); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); return true; } else if (id == R.id.action_exit) { stopIR(); System.exit(0); return true; } else if (id == R.id.action_update) { update(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.brq.wallet.activity.modern.ModernMain.java
private void checkGapBug() { final WalletManager walletManager = _mbwManager.getWalletManager(false); final List<Integer> gaps = walletManager.getGapsBug(); if (!gaps.isEmpty()) { try {/* w w w. j a va 2s . c o m*/ final List<Address> gapAddresses = walletManager.getGapAddresses(AesKeyCipher.defaultKeyCipher()); final String gapsString = Joiner.on(", ").join(gapAddresses); Log.d("Gaps", gapsString); final SpannableString s = new SpannableString( "Sorry to interrupt you... \n \nWe discovered a bug in the account logic that will make problems if you someday need to restore from your 12 word backup.\n\nFor further information see here: https://wallet.mycelium.com/info/gaps \n\nMay we try to resolve it for you? Press OK, to share one address per affected account with us."); Linkify.addLinks(s, Linkify.ALL); final AlertDialog d = new AlertDialog.Builder(this).setTitle("Account Gap").setMessage(s) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createPlaceHolderAccounts(gaps); _mbwManager.reportIgnoredException( new RuntimeException("Address gaps: " + gapsString)); } }).setNegativeButton("Ignore", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).show(); // Make the textview clickable. Must be called after show() ((TextView) d.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } catch (KeyCipher.InvalidKeyCipher invalidKeyCipher) { throw new RuntimeException(invalidKeyCipher); } } }
From source file:cat.ereza.customactivityoncrash.activity.DefaultErrorReportActivity.java
@SuppressLint("PrivateResource") @Override/* w w w .j a va 2s . co m*/ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); //This is needed to avoid a crash if the developer has not specified //an app-level theme that extends Theme.AppCompat TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme); if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) { setTheme(R.style.Theme_AppCompat_Light_DarkActionBar); } a.recycle(); setContentView(R.layout.customactivityoncrash_default_error_activity); //Close/restart button logic: //If a class if set, use restart. //Else, use close and just finish the app. //It is recommended that you follow this logic if implementing a custom error activity. Button restartButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_restart_button); final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent()); if (config.isShowRestartButton() && config.getRestartActivityClass() != null) { restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app); restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.restartApplication(DefaultErrorReportActivity.this, config); } }); } else { restartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomActivityOnCrash.closeApplication(DefaultErrorReportActivity.this, config); } }); } Button moreInfoButton = (Button) findViewById(R.id.customactivityoncrash_error_activity_more_info_button); if (config.isShowErrorDetails()) { moreInfoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //We retrieve all the error data and show it AlertDialog dialog = new AlertDialog.Builder(DefaultErrorReportActivity.this) .setTitle(R.string.customactivityoncrash_error_activity_error_details_title) .setMessage(CustomActivityOnCrash .getAllErrorDetailsFromIntent(DefaultErrorReportActivity.this, getIntent())) .setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null) .setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { copyErrorToClipboard(); Toast.makeText(DefaultErrorReportActivity.this, R.string.customactivityoncrash_error_activity_error_details_copied, Toast.LENGTH_SHORT).show(); } }) .show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources() .getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size)); } }); } else { moreInfoButton.setVisibility(View.GONE); } Integer defaultErrorActivityDrawableId = config.getErrorDrawable(); ImageView errorImageView = ((ImageView) findViewById(R.id.customactivityoncrash_error_activity_image)); if (defaultErrorActivityDrawableId != null) { errorImageView.setImageDrawable( ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme())); } }
From source file:com.oasis.sdk.activity.GooglePlayBillingActivity.java
/** * ??????// ww w .j a va2s .c o m * @param purchase */ void alert(final Purchase purchase) { final AlertDialog d = new AlertDialog.Builder(this).create(); d.show(); d.setContentView(BaseUtils.getResourceValue("layout", "oasisgames_sdk_common_dialog_notitle")); d.setCanceledOnTouchOutside(false); d.setCancelable(false); TextView retry = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_sure")); retry.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_retry"))); retry.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // ? d.dismiss(); setWaitScreen(true); check(purchase); } }); TextView close = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_cancle")); close.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_close"))); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { d.dismiss(); setResultInfo(OASISPlatformConstant.RESULT_EXCEPTION_GOOGLEPAY_EXCEPTION, "?????"); close(); } }); TextView content = (TextView) d .findViewById(BaseUtils.getResourceValue("id", "oasisgames_sdk_common_dialog_notitle_content")); content.setText(getResources() .getString(BaseUtils.getResourceValue("string", "oasisgames_sdk_pay_google_notice_alert_content"))); }