當前位置: 首頁>>代碼示例>>Java>>正文


Java InputFilter.LengthFilter方法代碼示例

本文整理匯總了Java中android.text.InputFilter.LengthFilter方法的典型用法代碼示例。如果您正苦於以下問題:Java InputFilter.LengthFilter方法的具體用法?Java InputFilter.LengthFilter怎麽用?Java InputFilter.LengthFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.InputFilter的用法示例。


在下文中一共展示了InputFilter.LengthFilter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCardIcon

import android.text.InputFilter; //導入方法依賴的package包/類
private Card setCardIcon(String source) {
    Card card = new CardValidator(source).guessCard();

    InputFilter[] FilterArray = new InputFilter[1];
    if (card != null) {
        int maxLength = Integer.parseInt(String.valueOf(card.getMaxLength()));
        FilterArray[0] = new InputFilter.LengthFilter(getSpacedPanLength(maxLength));
        mCardTextInputLayout.getEditText().setCompoundDrawablesRelativeWithIntrinsicBounds(ContextCompat.getDrawable(mCardTextInputLayout.getContext(), card.getDrawable()), null, null, null);
    } else {
        FilterArray[0] = new InputFilter.LengthFilter(getSpacedPanLength(19));
        mCardTextInputLayout.getEditText().setCompoundDrawablesRelativeWithIntrinsicBounds(ContextCompat.getDrawable(mCardTextInputLayout.getContext(), R.drawable.payment_method_generic_card), null, null, null);
    }

    mCardTextInputLayout.getEditText().setFilters(FilterArray);

    return card;
}
 
開發者ID:aksalj,項目名稱:africastalking-android,代碼行數:18,代碼來源:CardNumberTextWatcher.java

示例2: updateDropDownTextView

import android.text.InputFilter; //導入方法依賴的package包/類
private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && UserConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:22,代碼來源:PasscodeActivity.java

示例3: setMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
@ReactProp(name = "maxLength")
public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
  InputFilter [] currentFilters = view.getFilters();
  InputFilter[] newFilters = EMPTY_FILTERS;

  if (maxLength == null) {
    if (currentFilters.length > 0) {
      LinkedList<InputFilter> list = new LinkedList<>();
      for (int i = 0; i < currentFilters.length; i++) {
        if (!(currentFilters[i] instanceof InputFilter.LengthFilter)) {
          list.add(currentFilters[i]);
        }
      }
      if (!list.isEmpty()) {
        newFilters = (InputFilter[]) list.toArray(new InputFilter[list.size()]);
      }
    }
  } else {
    if (currentFilters.length > 0) {
      newFilters = currentFilters;
      boolean replaced = false;
      for (int i = 0; i < currentFilters.length; i++) {
        if (currentFilters[i] instanceof InputFilter.LengthFilter) {
          currentFilters[i] = new InputFilter.LengthFilter(maxLength);
          replaced = true;
        }
      }
      if (!replaced) {
        newFilters = new InputFilter[currentFilters.length + 1];
        System.arraycopy(currentFilters, 0, newFilters, 0, currentFilters.length);
        currentFilters[currentFilters.length] = new InputFilter.LengthFilter(maxLength);
      }
    } else {
      newFilters = new InputFilter[1];
      newFilters[0] = new InputFilter.LengthFilter(maxLength);
    }
  }

  view.setFilters(newFilters);
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:41,代碼來源:ReactTextInputManager.java

示例4: setMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
public void setMaxLength(int length) {
    InputFilter[] filters = getFilters();
    boolean have = false;
    InputFilter.LengthFilter lengthFilter = new InputFilter.LengthFilter(length);
    for (int i = 0; i < filters.length; i++) {
        InputFilter filter = filters[i];
        if (filter instanceof InputFilter.LengthFilter) {
            have = true;
            filters[i] = lengthFilter;
            setFilters(filters);
            break;
        }
    }
    if (!have) {
        addFilter(lengthFilter);
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:18,代碼來源:ExEditText.java

示例5: setMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
public void setMaxLength(int length, boolean addMoreStringLength) {
    InputFilter[] filters = getFilters();
    boolean have = false;
    InputFilter.LengthFilter lengthFilter = new InputFilter.LengthFilter(length + (addMoreStringLength ? getMoreString().length() : 0));
    for (int i = 0; i < filters.length; i++) {
        InputFilter filter = filters[i];
        if (filter instanceof InputFilter.LengthFilter) {
            have = true;
            filters[i] = lengthFilter;
            setFilters(filters);
            break;
        }
    }
    if (!have) {
        addFilter(lengthFilter);
    }

    setMaxLines(1);
    //setSingleLine();
    setEllipsize(TextUtils.TruncateAt.END);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:22,代碼來源:RTextView.java

示例6: createExact

import android.text.InputFilter; //導入方法依賴的package包/類
@SuppressLint("InflateParams")
private View createExact() {
    View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_exact, null);

    mExactViewA = (EditText) view.findViewById(R.id.exactA);
    mExactViewR = (EditText) view.findViewById(R.id.exactR);
    mExactViewG = (EditText) view.findViewById(R.id.exactG);
    mExactViewB = (EditText) view.findViewById(R.id.exactB);

    InputFilter[] filters = new InputFilter[]{new InputFilter.LengthFilter(2)};
    mExactViewA.setFilters(filters);
    mExactViewR.setFilters(filters);
    mExactViewG.setFilters(filters);
    mExactViewB.setFilters(filters);

    mExactViewA.setVisibility(mUseOpacityBar ? View.VISIBLE : View.GONE);

    setExactColor(mInitialColor);

    mExactColorPicker = (ColorWheelView) view.findViewById(R.id.picker_exact);
    mExactColorPicker.setOldCenterColor(mInitialColor);
    mExactColorPicker.setNewCenterColor(mNewColor);

    return view;
}
 
開發者ID:maysamrasoli,項目名稱:Doctor,代碼行數:26,代碼來源:ColorPickerDialog.java

示例7: inputFilter

import android.text.InputFilter; //導入方法依賴的package包/類
InputFilter[] inputFilter(final Context context) {
    InputFilter filters[] = new InputFilter[2];
    filters[0] = new InputFilter.LengthFilter(context.getResources().getInteger(R.integer.config_message_size));
    filters[1] = new InputFilter() {
        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            for(int index = start; index < end; index++) {
                if(!new String(charset).contains(String.valueOf(source.charAt(index)))) {
                    Toast toast = Toast.makeText(context, context.getString(R.string.invalid_char), Toast.LENGTH_SHORT);
                    toast.setGravity(Gravity.CENTER, 0, 0);
                    toast.show();
                    return "";
                }
            }

            return null;
        }
    };

    return filters;
}
 
開發者ID:gtom1984,項目名稱:Eulen,代碼行數:22,代碼來源:EulenOTP.java

示例8: lengthChineseFilter

import android.text.InputFilter; //導入方法依賴的package包/類
/**
 * 限製中文字符的長度
 */
public static void lengthChineseFilter(final EditText editText, final int length) {
    InputFilter[] filters = new InputFilter[1];

    filters[0] = new InputFilter.LengthFilter(length) {
        public CharSequence filter(@NonNull CharSequence source, int start, int end, @NonNull Spanned dest, int dstart, int dend) {
            // 可以檢查中文字符
            boolean isChinese = CharacterCheck.checkNameChese(source.toString());
            if (!isChinese || dest.toString().length() >= length) {
                return "";
            }
            return source;
        }
    };
    // Sets the list of input filters that will be used if the buffer is Editable. Has no effect otherwise.
    editText.setFilters(filters);
}
 
開發者ID:luhaoaimama1,項目名稱:zone-sdk,代碼行數:20,代碼來源:EditTextUtil.java

示例9: getEditTextMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static int getEditTextMaxLength(EditText editText){
    int length=0;
    InputFilter[] inputFilters = editText.getFilters();
    for(InputFilter filter:inputFilters){
        if(filter instanceof InputFilter.LengthFilter){
            length = ((InputFilter.LengthFilter) filter).getMax();
        }
    }
    return length;
}
 
開發者ID:nickyangjun,項目名稱:EasyEmoji,代碼行數:12,代碼來源:EmojiUtil.java

示例10: generateOneEditText

import android.text.InputFilter; //導入方法依賴的package包/類
/**
 * Takes care of styling the editText passed in the param.
 * tag is the index of the editText.
 *
 * @param styleEditText
 * @param tag
 */
private void generateOneEditText(EditText styleEditText, String tag) {
    params.setMargins(mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2, mSplitWidth / 2);
    filters[0] = new InputFilter.LengthFilter(1);
    styleEditText.setFilters(filters);
    styleEditText.setLayoutParams(params);
    styleEditText.setGravity(Gravity.CENTER);
    styleEditText.setCursorVisible(mCursorVisible);

    if (!mCursorVisible) {
        styleEditText.setClickable(false);
        styleEditText.setHint(mHint);

        styleEditText.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                // When back space is pressed it goes to delete mode and when u click on an edit Text it should get out of the delete mode
                mDelPressed = false;
                return false;
            }
        });
    }
    styleEditText.setBackgroundResource(mPinBackground);
    styleEditText.setPadding(0, 0, 0, 0);
    styleEditText.setTag(tag);
    styleEditText.setInputType(getKeyboardInputType());
    styleEditText.addTextChangedListener(this);
    styleEditText.setOnFocusChangeListener(this);
    styleEditText.setOnKeyListener(this);
}
 
開發者ID:GoodieBag,項目名稱:Pinview,代碼行數:37,代碼來源:Pinview.java

示例11: setMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
public void setMaxLength(final int newMaxLength) {
    this.maxLength = newMaxLength;
    InputFilter[] inputFilters = getFilters();
    for (int i = 0; i < inputFilters.length; i++) {
        if (inputFilters[i] instanceof InputFilter.LengthFilter) {
            inputFilters[i] = new InputFilter.LengthFilter(maxLength);
            break;
        }
    }
    this.setFilters(inputFilters);
    if (this.getText().toString().length() > maxLength) {
        this.setText(this.getText().toString().substring(0, maxLength));
    }
}
 
開發者ID:Adyen,項目名稱:adyen-android,代碼行數:15,代碼來源:CVCEditText.java

示例12: onCreateView

import android.text.InputFilter; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_login, container, false);
    _unbinder = ButterKnife.bind(this, view);

    InputFilter filter = new InputFilter.LengthFilter(PINCODE_LENGTH);
    _passwordInput.setFilters(new InputFilter[]{filter});

    return view;
}
 
開發者ID:StephanBezoen,項目名稱:tumblrlikes,代碼行數:12,代碼來源:LoginFragment.java

示例13: initFabText

import android.text.InputFilter; //導入方法依賴的package包/類
private void initFabText() {
    if (fabText == null || fabText.length() == 0) {
        return;
    }

    int maxLength = 25;
    InputFilter[] fArray = new InputFilter[1];
    fArray[0] = new InputFilter.LengthFilter(maxLength);
    setFilters(fArray);

    setEllipsize(TextUtils.TruncateAt.END);
    setTextColor(fabTextColor);
    setText(fabText);
    setAllCaps(fabTextAllCaps);
}
 
開發者ID:robertlevonyan,項目名稱:customFloatingActionButton,代碼行數:16,代碼來源:FloatingActionButton.java

示例14: lengthFilter

import android.text.InputFilter; //導入方法依賴的package包/類
/**
 * 限製內容長度
 */
public static void lengthFilter(final EditText editText, final int length) {
    InputFilter[] filters = new InputFilter[1];

    filters[0] = new InputFilter.LengthFilter(length) {
        public CharSequence filter(@NonNull CharSequence source, int start, int end, @NonNull Spanned dest, int dstart, int dend) {
            if (dest.toString().length() >= length) {
                return "";
            }
            return source;
        }
    };
    // Sets the list of input filters that will be used if the buffer is Editable. Has no effect otherwise.
    editText.setFilters(filters);
}
 
開發者ID:luhaoaimama1,項目名稱:zone-sdk,代碼行數:18,代碼來源:EditTextUtil.java

示例15: setMaxLength

import android.text.InputFilter; //導入方法依賴的package包/類
@ReactProp(name = "maxLength")
public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) {
  InputFilter [] currentFilters = view.getFilters();
  InputFilter[] newFilters = EMPTY_FILTERS;

  if (maxLength == null) {
    if (currentFilters.length > 0) {
      LinkedList<InputFilter> list = new LinkedList<>();
      for (int i = 0; i < currentFilters.length; i++) {
        if (!(currentFilters[i] instanceof InputFilter.LengthFilter)) {
          list.add(currentFilters[i]);
        }
      }
      if (!list.isEmpty()) {
        newFilters = (InputFilter[]) list.toArray();
      }
    }
  } else {
    if (currentFilters.length > 0) {
      newFilters = currentFilters;
      boolean replaced = false;
      for (int i = 0; i < currentFilters.length; i++) {
        if (currentFilters[i] instanceof InputFilter.LengthFilter) {
          currentFilters[i] = new InputFilter.LengthFilter(maxLength);
          replaced = true;
        }
      }
      if (!replaced) {
        newFilters = new InputFilter[currentFilters.length + 1];
        System.arraycopy(currentFilters, 0, newFilters, 0, currentFilters.length);
        currentFilters[currentFilters.length] = new InputFilter.LengthFilter(maxLength);
      }
    } else {
      newFilters = new InputFilter[1];
      newFilters[0] = new InputFilter.LengthFilter(maxLength);
    }
  }

  view.setFilters(newFilters);
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:41,代碼來源:ReactTextInputManager.java


注:本文中的android.text.InputFilter.LengthFilter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。