androidx.appcompat.app.AlertDialog.findViewById()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中androidx.appcompat.app.AlertDialog.findViewById()方法的一些代码示例,展示了AlertDialog.findViewById()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlertDialog.findViewById()方法的具体详情如下:
包路径:androidx.appcompat.app.AlertDialog
类名称:AlertDialog
方法名:findViewById

AlertDialog.findViewById介绍

暂无

代码示例

代码示例来源:origin: mikepenz/AboutLibraries

@Override
  public void onClick(View v) {
    boolean consumed = false;
    if (LibsConfiguration.getInstance().getListener() != null) {
      consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL1);
    }
    if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial1Description)) {
      try {
        AlertDialog alert = new AlertDialog.Builder(ctx)
            .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial1Description))
            .create();
        alert.show();
        TextView alertText = (TextView) alert.findViewById(android.R.id.message);
        if (alertText != null) {
          alertText.setMovementMethod(LinkMovementMethod.getInstance());
        }
      } catch (Exception ex) {
      }
    }
  }
});

代码示例来源:origin: mikepenz/AboutLibraries

@Override
  public void onClick(View v) {
    boolean consumed = false;
    if (LibsConfiguration.getInstance().getListener() != null) {
      consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL3);
    }
    if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial3Description)) {
      try {
        AlertDialog alert = new AlertDialog.Builder(ctx)
            .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial3Description))
            .create();
        alert.show();
        TextView alertText = (TextView) alert.findViewById(android.R.id.message);
        if (alertText != null) {
          alertText.setMovementMethod(LinkMovementMethod.getInstance());
        }
      } catch (Exception ex) {
      }
    }
  }
});

代码示例来源:origin: mikepenz/AboutLibraries

@Override
  public void onClick(View v) {
    boolean consumed = false;
    if (LibsConfiguration.getInstance().getListener() != null) {
      consumed = LibsConfiguration.getInstance().getListener().onExtraClicked(v, Libs.SpecialButton.SPECIAL2);
    }
    if (!consumed && !TextUtils.isEmpty(libsBuilder.aboutAppSpecial2Description)) {
      try {
        AlertDialog alert = new AlertDialog.Builder(ctx)
            .setMessage(Html.fromHtml(libsBuilder.aboutAppSpecial2Description))
            .create();
        alert.show();
        TextView alertText = (TextView) alert.findViewById(android.R.id.message);
        if (alertText != null) {
          alertText.setMovementMethod(LinkMovementMethod.getInstance());
        }
      } catch (Exception ex) {
      }
    }
  }
});

代码示例来源:origin: westnordost/StreetComplete

View messageView = dialog.findViewById(android.R.id.message);
if(messageView != null && messageView instanceof TextView)

代码示例来源:origin: proninyaroslav/libretorrent

private void initAboutDialog(final AlertDialog dialog)
{
  TextView version = dialog.findViewById(R.id.about_version);
  if (version != null) {
    String versionName = Utils.getAppVersionName(activity);
    if (versionName != null)
      version.setText(versionName);
  }
}

代码示例来源:origin: offensive-security/nethunter-app

@Override
  public void onClick(DialogInterface dialog, int which) {
    statusLog("Everything went fine, chroot is installed. Selecting metapackages.");
    StringBuilder sb = new StringBuilder("");
    CheckBox cb;
    // now grab all the checkboxes in the dialog and check their status
    // thanks to "user2" for a 2-line sample of how to get the dialog's view:  http://stackoverflow.com/a/13959585/3035127
    AlertDialog d = AlertDialog.class.cast(dialog);
    LinearLayout ll = (LinearLayout) d.findViewById(R.id.metapackageLinearLayout);
    int children = ll.getChildCount();
    for (int cnt = 0; cnt < children; cnt++) {
      if (ll.getChildAt(cnt) instanceof CheckBox) {
        cb = (CheckBox) ll.getChildAt(cnt);
        if (cb.isChecked()) {
          sb.append(cb.getText()).append(" ");
        }
      }
    }
    installAndUpgrade(sb.toString());
  }
});

代码示例来源:origin: proninyaroslav/libretorrent

private void initTorrentSortingDialog(final AlertDialog dialog)
{
  Spinner sp = dialog.findViewById(R.id.dialog_sort_by);
  RadioGroup group = dialog.findViewById(R.id.dialog_sort_direction);
  if (sp != null && group != null) {
    String[] columns = activity.getResources().getStringArray(R.array.sort_torrent_values);
    String column = pref.getString(getString(R.string.pref_key_sort_torrent_by),
                    SettingsManager.Default.sortTorrentBy);
    String direction = pref.getString(getString(R.string.pref_key_sort_torrent_direction),
                     SettingsManager.Default.sortTorrentDirection);
    ArrayAdapter<String> adapter = new ArrayAdapter<>(activity,
        R.layout.spinner_item_dropdown,
        getResources().getStringArray(R.array.sort_torrent_by));
    sp.setAdapter(adapter);
    sp.setSelection(Arrays.asList(columns).indexOf(column));
    if (TorrentSorting.Direction.fromValue(direction) == TorrentSorting.Direction.ASC)
      group.check(R.id.dialog_sort_by_ascending);
    else
      group.check(R.id.dialog_sort_by_descending);
  }
}

代码示例来源:origin: bfabiszewski/ulogger-android

/**
 * Display About dialog
 */
private void showAbout() {
  final AlertDialog dialog = showAlert(MainActivity.this,
      getString(R.string.app_name),
      R.layout.about,
      R.drawable.ic_ulogger_logo_24dp);
  final TextView versionLabel = dialog.findViewById(R.id.about_version);
  if (versionLabel != null) {
    versionLabel.setText(getString(R.string.about_version, BuildConfig.VERSION_NAME));
  }
  final TextView descriptionLabel = dialog.findViewById(R.id.about_description);
  final TextView description2Label = dialog.findViewById(R.id.about_description2);
  if (descriptionLabel != null && description2Label != null) {
    descriptionLabel.setText(HtmlCompat.fromHtml(getString(R.string.about_description), HtmlCompat.FROM_HTML_MODE_LEGACY));
    description2Label.setText(HtmlCompat.fromHtml(getString(R.string.about_description2), HtmlCompat.FROM_HTML_MODE_LEGACY));
  }
  final Button okButton = dialog.findViewById(R.id.about_button_ok);
  if (okButton != null) {
    okButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        dialog.dismiss();
      }
    });
  }
}

代码示例来源:origin: bfabiszewski/ulogger-android

getString(R.string.title_newtrack),
    R.layout.newtrack_dialog);
final EditText editText = dialog.findViewById(R.id.newtrack_edittext);
if (editText == null) {
  return;
final Button submit = dialog.findViewById(R.id.newtrack_button_submit);
if (submit != null) {
  submit.setOnClickListener(new View.OnClickListener() {
final Button cancel = dialog.findViewById(R.id.newtrack_button_cancel);
if (cancel != null) {
  cancel.setOnClickListener(new View.OnClickListener() {

代码示例来源:origin: bfabiszewski/ulogger-android

preference.getTitle(),
    R.layout.other_dialog);
final TextView textView = dialog.findViewById(R.id.other_textview);
final EditText editText = dialog.findViewById(R.id.other_edittext);
final Button submit = dialog.findViewById(R.id.other_button_submit);
final Button cancel = dialog.findViewById(R.id.other_button_cancel);
if (textView == null || editText == null || submit == null || cancel == null) {
  return;

代码示例来源:origin: bfabiszewski/ulogger-android

final AlertDialog dialog = (AlertDialog) getDialog();
if (dialog != null) {
  final EditText editText = dialog.findViewById(android.R.id.edit);
  Button positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE);
  if (editText != null && positiveButton != null) {

代码示例来源:origin: proninyaroslav/libretorrent

RadioButton button = dialog.findViewById(resId);
if (button != null) {
  button.setChecked(true);
RadioGroup group = dialog.findViewById(R.id.dialog_priorities_group);
if (group != null) {
  group.clearCheck();

代码示例来源:origin: vbier/habpanelviewer

@Override
  public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler, final String host, final String realm) {
    Log.i(TAG, "realm " + realm);
    CredentialsHelper.getInstance(getContext()).handleAuthRequest(host, realm, handler, () -> {
      final AlertDialog alert = new AlertDialog.Builder(getContext())
          .setCancelable(false)
          .setTitle(R.string.credentials_required)
          .setMessage(getContext().getString(R.string.host_realm, host, realm))
          .setView(R.layout.dialog_credentials)
          .setPositiveButton(R.string.okay, (dialog12, id) -> {
            EditText userT = ((AlertDialog) dialog12).findViewById(R.id.username);
            EditText passT = ((AlertDialog) dialog12).findViewById(R.id.password);
            CheckBox storeCB = ((AlertDialog) dialog12).findViewById(R.id.checkBox);
            if (storeCB.isChecked()) {
              CredentialsHelper.getInstance(getContext()).registerCredentials(host, realm, userT.getText().toString(), passT.getText().toString());
            }
            handler.proceed(userT.getText().toString(), passT.getText().toString());
          }).setNegativeButton(R.string.cancel, (dialog1, which) -> handler.cancel())
          .create();
      if (getContext() != null && !((Activity) getContext()).isFinishing()) {
        alert.show();
      }
    });
  }
});

代码示例来源:origin: bfabiszewski/ulogger-android

R.layout.summary,
    R.drawable.ic_equalizer_white_24dp);
final Button okButton = dialog.findViewById(R.id.summary_button_ok);
if (okButton != null) {
  okButton.setOnClickListener(new View.OnClickListener() {
final TextView summaryDistance = dialog.findViewById(R.id.summary_distance);
final TextView summaryDuration = dialog.findViewById(R.id.summary_duration);
final TextView summaryPositions = dialog.findViewById(R.id.summary_positions);
double distance = (double) summary.getDistance() / 1000;
String unitName = getString(R.string.unit_kilometer);

代码示例来源:origin: proninyaroslav/libretorrent

private void initAddDialog(final AlertDialog dialog)
  final TextInputEditText field = dialog.findViewById(R.id.text_input_dialog);
  final TextInputLayout fieldLayout = dialog.findViewById(R.id.layout_text_input_dialog);

代码示例来源:origin: raphaelbussa/PermissionUtils

AlertDialog dialog = builder.create();
dialog.show();
TextView textView = dialog.findViewById(android.R.id.message);
if (textView != null) {
  textView.setMovementMethod(LinkMovementMethod.getInstance());

代码示例来源:origin: proninyaroslav/libretorrent

if (fm != null && (fm.findFragmentByTag(TAG_ADD_CHANNEL_DIALOG) != null ||
  fm.findFragmentByTag(TAG_EDIT_CHANNEL_DIALOG) != null)) {
  final TextInputEditText urlField = dialog.findViewById(R.id.feed_channel_url);
  final TextInputLayout urlFieldLayout = dialog.findViewById(R.id.layout_feed_channel_url);
  final TextInputEditText filterField = dialog.findViewById(R.id.feed_channel_filter);
  final TextInputLayout filterFieldLayout = dialog.findViewById(R.id.layout_feed_channel_filter);
  final CheckBox isRegexFilter = dialog.findViewById(R.id.feed_use_regex);
  final CheckBox autoDownloadField = dialog.findViewById(R.id.feed_auto_download);
  final CheckBox noDownloadImmediatelyField = dialog.findViewById(R.id.feed_do_not_download_immediately);
  final TextInputEditText nameField = dialog.findViewById(R.id.feed_channel_name);
  final ExpandableLinearLayout expandableLayout = dialog.findViewById(R.id.expandable_layout);

代码示例来源:origin: raphaelbussa/HeaderView

@Override
public boolean onMenuItemClick(MenuItem item) {
  switch (item.getItemId()) {
    case R.id.action_info:
      AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
      builder.setTitle(getString(R.string.action_info));
      builder.setMessage(fromHtml(getString(R.string.info_message)));
      builder.setPositiveButton(getString(R.string.close), null);
      AlertDialog dialog = builder.create();
      dialog.show();
      TextView textView = dialog.findViewById(android.R.id.message);
      if (textView != null) {
        textView.setMovementMethod(LinkMovementMethod.getInstance());
      }
      return true;
    default:
      return false;
  }
}

代码示例来源:origin: proninyaroslav/libretorrent

dialog.findViewById(R.id.multiline_text_input_dialog);
final TextInputLayout fieldLayout =
    dialog.findViewById(R.id.layout_multiline_text_input_dialog);
TextInputEditText upload = dialog.findViewById(R.id.upload_limit);
TextInputEditText download = dialog.findViewById(R.id.download_limit);

代码示例来源:origin: PSDev/LicensesDialog

final View titleDivider = dialog.findViewById(titleDividerId);
if (titleDivider != null) {
  titleDivider.setBackgroundColor(mDividerColor);

相关文章