当前位置: 首页>>代码示例>>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;未经允许,请勿转载。