com.google.android.material.textfield.TextInputLayout.setHint()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(112)

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

TextInputLayout.setHint介绍

暂无

代码示例

代码示例来源:origin: michael-rapp/AndroidMaterialDialog

/**
 * Adapts the hint of the dialog's edit text widget.
 */
private void adaptHint() {
  if (textInputLayout != null) {
    textInputLayout.setHint(hint);
  } else if (editText != null) {
    editText.setHint(hint);
  }
}

代码示例来源:origin: stripe/stripe-android

private void renderLabels() {
  mNameTextInputLayout.setHint(getResources().getString(R.string.address_label_name));
  if (mOptionalShippingInfoFields.contains(CITY_FIELD)) {
    mCityTextInputLayout.setHint(getResources().getString(R.string
        .address_label_city_optional));
  } else {
    mCityTextInputLayout.setHint(getResources().getString(R.string.address_label_city));
  }
  if (mOptionalShippingInfoFields.contains(PHONE_FIELD)) {
    mPhoneNumberTextInputLayout.setHint(getResources().getString(R.string
        .address_label_phone_number_optional));
  } else {
    mPhoneNumberTextInputLayout.setHint(getResources().getString(R.string
        .address_label_phone_number));
  }
  hideHiddenFields();
}

代码示例来源:origin: stripe/stripe-android

private void renderUSForm() {
  if (mOptionalShippingInfoFields.contains(ADDRESS_LINE_ONE_FIELD)) {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_optional));
  } else {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address));
  }
  mAddressLine2TextInputLayout.setHint(getResources().getString(R.string
      .address_label_apt_optional));
  if (mOptionalShippingInfoFields.contains(POSTAL_CODE_FIELD)) {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_zip_code_optional));
  } else {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_zip_code));
  }
  if (mOptionalShippingInfoFields.contains(STATE_FIELD)) {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_state_optional));
  } else {
    mStateTextInputLayout.setHint(getResources().getString(R.string.address_label_state));
  }
  mPostalCodeEditText.setErrorMessage(getResources().getString(R.string.address_zip_invalid));
  mStateEditText.setErrorMessage(getResources().getString(R.string.address_state_required));
}

代码示例来源:origin: stripe/stripe-android

private void renderCanadianForm() {
  if (mOptionalShippingInfoFields.contains(ADDRESS_LINE_ONE_FIELD)) {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_optional));
  } else {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address));
  }
  mAddressLine2TextInputLayout.setHint(getResources().getString(R.string
      .address_label_apt_optional));
  if (mOptionalShippingInfoFields.contains(POSTAL_CODE_FIELD)) {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_postal_code_optional));
  } else {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_postal_code));
  }
  if (mOptionalShippingInfoFields.contains(STATE_FIELD)) {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_province_optional));
  } else {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_province));
  }
  mPostalCodeEditText.setErrorMessage(getResources().getString(R.string
      .address_postal_code_invalid));
  mStateEditText.setErrorMessage(getResources().getString(R.string
      .address_province_required));
}

代码示例来源:origin: stripe/stripe-android

private void renderGreatBritainForm() {
  if (mOptionalShippingInfoFields.contains(ADDRESS_LINE_ONE_FIELD)) {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_line1_optional));
  } else {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_line1));
  }
  mAddressLine2TextInputLayout.setHint(getResources().getString(R.string
      .address_label_address_line2_optional));
  if (mOptionalShippingInfoFields.contains(POSTAL_CODE_FIELD)) {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_postcode_optional));
  } else {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_postcode));
  }
  if (mOptionalShippingInfoFields.contains(STATE_FIELD)) {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_county_optional));
  } else {
    mStateTextInputLayout.setHint(getResources().getString(R.string.address_label_county));
  }
  mPostalCodeEditText.setErrorMessage(getResources().getString(R.string
      .address_postcode_invalid));
  mStateEditText.setErrorMessage(getResources().getString(R.string.address_county_required));
}

代码示例来源:origin: stripe/stripe-android

private void updateCvc(@NonNull @Card.CardBrand String brand) {
  if (Card.AMERICAN_EXPRESS.equals(brand)) {
    mCvcEditText.setFilters(
        new InputFilter[]{
            new InputFilter.LengthFilter(Card.CVC_LENGTH_AMERICAN_EXPRESS)
        });
    mCvcTextInputLayout.setHint(getResources().getString(R.string.cvc_amex_hint));
  } else {
    mCvcEditText.setFilters(
        new InputFilter[]{
            new InputFilter.LengthFilter(Card.CVC_LENGTH_COMMON)});
    mCvcTextInputLayout.setHint(getResources().getString(R.string.cvc_number_hint));
  }
}

代码示例来源:origin: stripe/stripe-android

private void renderInternationalForm() {
  if (mOptionalShippingInfoFields.contains(ADDRESS_LINE_ONE_FIELD)) {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_line1_optional));
  } else {
    mAddressLine1TextInputLayout.setHint(getResources().getString(R.string
        .address_label_address_line1));
  }
  mAddressLine2TextInputLayout.setHint(getResources().getString(R.string
      .address_label_address_line2_optional));
  if (mOptionalShippingInfoFields.contains(POSTAL_CODE_FIELD)) {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_zip_postal_code_optional));
  } else {
    mPostalCodeTextInputLayout.setHint(getResources().getString(R.string
        .address_label_zip_postal_code));
  }
  if (mOptionalShippingInfoFields.contains(STATE_FIELD)) {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_region_generic_optional));
  } else {
    mStateTextInputLayout.setHint(getResources().getString(R.string
        .address_label_region_generic));
  }
  mPostalCodeEditText.setErrorMessage(getResources().getString(R.string
      .address_zip_postal_invalid));
  mStateEditText.setErrorMessage(getResources().getString(R.string
      .address_region_generic_required));
}

代码示例来源:origin: heinrichreimer/android-issue-reporter

protected final void setGuestEmailRequired(boolean required) {
  this.emailRequired = required;
  if (required) {
    optionAnonymous.setText(R.string.air_label_use_email);
    ((TextInputLayout) findViewById(R.id.air_inputEmailParent)).setHint(getString(R.string.air_label_email));
  } else {
    optionAnonymous.setText(R.string.air_label_use_guest);
    ((TextInputLayout) findViewById(R.id.air_inputEmailParent)).setHint(getString(R.string.air_label_email_optional));
  }
}

代码示例来源:origin: searchy2/CustomAlertViewDialogue

inputLayout.setHint(builder.getLineInputHint().get(i));
TextInputEditText editInput = lineInput.findViewById(R.id.alert_input_text);
editInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
inputLayout.setHint(builder.getBoxInputHint().get(i));
EditText editInput = boxInput.findViewById(R.id.alert_input_text);
if (builder.getBoxInputText().size() > i)

代码示例来源:origin: stripe/stripe-android

void adjustViewForPostalCodeAttribute() {
  // Set the label/hint to the shorter value if we have three things in a row.
  @StringRes final int expiryLabel = mShouldShowPostalCode
      ? R.string.expiry_label_short
      : R.string.acc_label_expiry_date;
  mExpiryTextInputLayout.setHint(getResources().getString(expiryLabel));
  @IdRes final int focusForward = mShouldShowPostalCode
      ? R.id.et_add_source_postal_ml
      : NO_ID;
  mCvcEditText.setNextFocusForwardId(focusForward);
  mCvcEditText.setNextFocusDownId(focusForward);
  final int postalCodeVisibility = mShouldShowPostalCode ? View.VISIBLE : View.GONE;
  mPostalInputLayout.setVisibility(postalCodeVisibility);
  // If the postal code field is not shown, the CVC field is the last one in the form and the
  // action on the keyboard when the CVC field is focused should be "Done". Otherwise, show
  // the "Next" action.
  mCvcEditText.setImeOptions(postalCodeVisibility == View.GONE ?
      EditorInfo.IME_ACTION_DONE : EditorInfo.IME_ACTION_NEXT);
  final int marginPixels = mShouldShowPostalCode
      ? getResources().getDimensionPixelSize(R.dimen.add_card_expiry_middle_margin)
      : 0;
  final LinearLayout.LayoutParams linearParams =
      (LinearLayout.LayoutParams) mCvcTextInputLayout.getLayoutParams();
  linearParams.setMargins(0, 0, marginPixels, 0);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    linearParams.setMarginEnd(marginPixels);
  }
  mCvcTextInputLayout.setLayoutParams(linearParams);
}

代码示例来源:origin: stripe/stripe-android

mExpiryTextInputLayout.setHint(getResources().getString(R.string.expiry_label_short));

相关文章