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


Java EditText.setFilters方法代碼示例

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


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

示例1: keepEditTwoPoint

import android.widget.EditText; //導入方法依賴的package包/類
public static void keepEditTwoPoint(EditText editText) {
    editText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
    editText.setFilters(new InputFilter[]{new InputFilter() {
        @Override
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
            if (source.equals(".") && dest.toString().length() == 0) {
                return "0.";
            }
            if (dest.toString().contains(".")) {
                int index = dest.toString().indexOf(".");
                int mlength = dest.toString().substring(index).length();
                if (mlength == 3) {
                    return "";
                }
            }
            return null;
        }
    }});
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:20,代碼來源:NormalUtil.java

示例2: setEditable

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * Input frame character length limit
 *
 * @param mEdit     EditText
 * @param maxLength maxLength
 */
public void setEditable(EditText mEdit, int maxLength) {
    if (mEdit.getText().length() < maxLength) {
        mEdit.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxLength) {
        }});
        mEdit.setCursorVisible(true);
        mEdit.setFocusableInTouchMode(true);
        mEdit.requestFocus();
    } else {
        mEdit.setFilters(new InputFilter[]{new InputFilter() {
            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
                return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
            }
        }});
        mEdit.setCursorVisible(false);
        mEdit.setFocusableInTouchMode(false);
        mEdit.clearFocus();
    }
}
 
開發者ID:Jusenr,項目名稱:androidtools,代碼行數:26,代碼來源:StringUtils.java

示例3: NumberPicker

import android.widget.EditText; //導入方法依賴的package包/類
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);
    
    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setOnFocusChangeListener(this);
    mText.setFilters(new InputFilter[] {inputFilter});
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);

    if (!isEnabled()) {
        setEnabled(false);
    }
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:27,代碼來源:NumberPicker.java

示例4: generateOneEditText

import android.widget.EditText; //導入方法依賴的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

示例5: onInitialized

import android.widget.EditText; //導入方法依賴的package包/類
@Override
public void onInitialized(MainPresenter presenter, MainViewState viewState) {
    if (!presenter.isInitialized()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.enter_key);
        builder.setMessage(R.string.key_requirments_message);

        EditText editText = new EditText(this);
        editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(16)});
        builder.setView(editText);

        builder.setPositiveButton(R.string.apply, null);

        AlertDialog dialog = builder.create();
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();

        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
            if (editText.getText().length() == 16) {
                String key = editText.getText().toString();
                presenter.initializeWithKey(key);
                presenter.getValues();
                dialog.dismiss();
            } else {
                Toast.makeText(this, R.string.bad_key, Toast.LENGTH_LONG).show();
            }
        });

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) editText.getLayoutParams();
        int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, getResources().getDisplayMetrics());
        layoutParams.setMargins(margin, margin, margin, margin);
        editText.requestLayout();
    } else {
        if (!viewState.isPrefsLoaded() && !presenter.isTaskRunning(MainPresenter.TASK_GET_RUNNING)) {
            presenter.getValues();
        }
    }
}
 
開發者ID:Ufkoku,項目名稱:CipherSharedPrefs,代碼行數:40,代碼來源:MainActivity.java

示例6: AddSpaceTextWatcher

import android.widget.EditText; //導入方法依賴的package包/類
public AddSpaceTextWatcher(Activity activity, EditText editText, int maxLenght) {
    this.activity=activity;
    this.editText = editText;
    this.maxLenght = maxLenght;
    if (editText == null) {
        new NullPointerException("editText is null");
    }
    spaceType = SpaceType.defaultType;
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(
            maxLenght)});
    editText.addTextChangedListener(this);
}
 
開發者ID:wenzhimin,項目名稱:BootStepView,代碼行數:13,代碼來源:AddSpaceTextWatcher.java

示例7: setupEditText

import android.widget.EditText; //導入方法依賴的package包/類
protected void setupEditText(EditText editText) {
	editText.setInputType(InputType.TYPE_NULL);
	editText.setFilters(filters);
	editText.setOnTouchListener(touchListener);
	editText.setTransformationMethod(PasswordTransformationMethod
			.getInstance());
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:8,代碼來源:AppLockActivity.java

示例8: initView

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * Init number picker by disabling focusability of edit text embedded inside the number picker
 * We also override the edit text filter private attribute by using reflection as the formatter is still buggy while attempting to display the default value
 * This is still an open Google @see <a href="https://code.google.com/p/android/issues/detail?id=35482#c9">issue</a> from 2012
 */
private void initView() {

    try {
        Field f = NumberPicker.class.getDeclaredField("mInputText");
        f.setAccessible(true);
        EditText inputText = (EditText) f.get(this);
        inputText.setFilters(new InputFilter[0]);
    } catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
        //We do not really want to display the errors, since we are a lib
    }
}
 
開發者ID:Commit451,項目名稱:FitterNumberPicker,代碼行數:17,代碼來源:FitterNumberPicker.java

示例9: setupSecondEditText

import android.widget.EditText; //導入方法依賴的package包/類
protected void setupSecondEditText(boolean visible) {
    mSecondEditText = (EditText) findViewById(R.id.seconds);
    if (visible) {
        mSecondEditText.setFilters(new InputFilter[]{new InputFilterMinMax("0", "59"), new InputFilter.LengthFilter(2)});
        mSecondEditText.addTextChangedListener(mSecondTextWatcher);
    } else {
        mSecondEditText.setVisibility(View.GONE);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:10,代碼來源:TimePickerView.java

示例10: setupMinuteEditText

import android.widget.EditText; //導入方法依賴的package包/類
protected void setupMinuteEditText(boolean visible) {
    mMinuteEditText = (EditText) findViewById(R.id.minute);
    if (visible) {
        mMinuteEditText.setFilters(new InputFilter[]{new InputFilterMinMax("0", "59"), new InputFilter.LengthFilter(2)});
        mMinuteEditText.addTextChangedListener(mMinuteTextWatcher);
    } else {
        mMinuteEditText.setVisibility(View.GONE);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:10,代碼來源:TimePickerView.java

示例11: setupHourEditText

import android.widget.EditText; //導入方法依賴的package包/類
protected void setupHourEditText(boolean visible) {
    mHourEditText = (EditText) findViewById(R.id.hour);
    if (visible) {
        mHourEditText.setFilters(new InputFilter[]{new InputFilterMinMax("0", "10"), new InputFilter.LengthFilter(2)});
        mHourEditText.addTextChangedListener(mHourTextWatcher);
    } else {
        mHourEditText.setVisibility(View.GONE);
        findViewById(R.id.hour_divider).setVisibility(View.GONE);
    }
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:11,代碼來源:TimePickerView.java

示例12: init

import android.widget.EditText; //導入方法依賴的package包/類
private void init() {
    inflate(getContext(), R.layout.view_edittext, this);
    editText = (EditText) findViewById(R.id.ev_content);
    textView = (TextView) findViewById(R.id.tv_num);
    textView.setText(String.format(mCurrentCount, 0));
    editText.addTextChangedListener(this);
    editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(30)});
}
 
開發者ID:shenhuanet,項目名稱:OpenEyesReading-android,代碼行數:9,代碼來源:AutoEditText.java

示例13: setShowAlphaDigits

import android.widget.EditText; //導入方法依賴的package包/類
public static void setShowAlphaDigits(final EditText hexEdit, boolean showAlphaDigits) {
	hexEdit.setFilters(showAlphaDigits ? withAlphaDigits : withoutAlphaDigits);
	hexEdit.setText(hexEdit.getText()); // trigger a reformat of text
}
 
開發者ID:salim3dd,項目名稱:hsv-alpha-color-picker,代碼行數:5,代碼來源:HexEdit.java

示例14: setProhibitEmoji

import android.widget.EditText; //導入方法依賴的package包/類
public  void setProhibitEmoji(EditText et)
{
    InputFilter[] filters = { getInputFilterProhibitEmoji() ,getInputFilterProhibitSP()};
    et.setFilters(filters);
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:6,代碼來源:ChatActivity.java

示例15: onCreateView

import android.widget.EditText; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View V = inflater.inflate(R.layout.fragment_edit, container, false);

    CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    int index = getArguments().getInt("INDEX");
    Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(m.GetRow());
    gridLayout.setColumnCount(m.GetCol());
    for (int i = 0; i < m.GetRow(); i++) {
        for (int j = 0; j < m.GetCol(); j++) {
            EditText editText = new EditText(getContext());
            editText.setId(i * 10 + j);
            editText.setGravity(Gravity.CENTER);
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
                editText.setWidth(ConvertTopx(62));
                editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
                        getBoolean("EXTRA_SMALL_FONT", false)));
            } else {
                editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
                editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
                        PreferenceManager.getDefaultSharedPreferences(getContext()).
                                getBoolean("EXTRA_SMALL_FONT", false)));
            }
            editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
            editText.setSingleLine();
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(editText, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);
    RootView = V;
    return V;
}
 
開發者ID:coder3101,項目名稱:Matrix-Calculator-for-Android,代碼行數:60,代碼來源:EditFragment.java


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