当前位置: 首页>>代码示例>>Java>>正文


Java DigitsKeyListener类代码示例

本文整理汇总了Java中android.text.method.DigitsKeyListener的典型用法代码示例。如果您正苦于以下问题:Java DigitsKeyListener类的具体用法?Java DigitsKeyListener怎么用?Java DigitsKeyListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DigitsKeyListener类属于android.text.method包,在下文中一共展示了DigitsKeyListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
@Override
protected void onCreate( Bundle savedInstanceState )
{
	super.onCreate( savedInstanceState );
	penClient = PenClientCtrl.getInstance( getApplicationContext() );
	if(penClient.getProtocolVersion() == 1)
		addPreferencesFromResource( R.xml.pref_settings );
	else
		addPreferencesFromResource( R.xml.pref_settings2 );



	mPasswordPref = (EditTextPreference) getPreferenceScreen().findPreference( Const.Setting.KEY_PASSWORD );

	EditText myEditText = (EditText) mPasswordPref.getEditText();
	myEditText.setKeyListener( DigitsKeyListener.getInstance( false, true ) );
}
 
开发者ID:NeoSmartpen,项目名称:AndroidSDK2.0,代码行数:18,代码来源:SettingActivity.java

示例2: updateDropDownTextView

import android.text.method.DigitsKeyListener; //导入依赖的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: setInputType

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
@Override
public void setInputType(int type) {
    if (type == -1) {
        type = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD;
    }

    if (type == InputType.TYPE_CLASS_NUMBER ||
            type == InputType.TYPE_NUMBER_FLAG_SIGNED ||
            type == InputType.TYPE_NUMBER_FLAG_DECIMAL ||
            type == InputType.TYPE_CLASS_PHONE) {
        final String symbolExceptions = getSymbolExceptions();
        this.setKeyListener(DigitsKeyListener.getInstance("0123456789." + symbolExceptions));
    } else {
        super.setInputType(type);
    }
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:17,代码来源:MaskedEditText.java

示例4: updateInputMethod

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
protected void updateInputMethod() {
    boolean hasNumberField = mNumberField != null;
    setEnabled(hasNumberField);

    if (hasNumberField) {
        int imeOptions = InputType.TYPE_CLASS_NUMBER;
        StringBuilder allowedChars = new StringBuilder("0123456789");
        if (mAllowExponent) {
            allowedChars.append("e");
        }

        if (mNumberField.getMinimumValue() < 0) {
            imeOptions |= InputType.TYPE_NUMBER_FLAG_SIGNED;
            allowedChars.append("-");
        }
        if (!mNumberField.isInteger()) {
            imeOptions |= InputType.TYPE_NUMBER_FLAG_DECIMAL;
            allowedChars.append(mLocalizedDecimalSymbols.getDecimalSeparator());
        }
        allowedChars.append(mLocalizedDecimalSymbols.getGroupingSeparator());

        setImeOptions(imeOptions);
        setKeyListener(DigitsKeyListener.getInstance(allowedChars.toString()));
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:26,代码来源:BasicFieldNumberView.java

示例5: setMode

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
public void setMode(EditMode value) {
    m_editMode = value;

    switch (EffectiveMode()) {
        case HHMM:
            this.setHint(R.string.emptyWaterMarkHHMM);
            this.setInputType(InputType.TYPE_CLASS_NUMBER);
            setKeyListener(DigitsKeyListener.getInstance(false, false));
            break;
        case INTEGER:
            this.setHint(R.string.emptyWaterMarkInt);
            this.setInputType(InputType.TYPE_CLASS_NUMBER);
            this.setKeyListener(DigitsKeyListener.getInstance(false, false));
            // setKeyListener(DigitsKeyListener.getInstance("01234567890"));
            break;
        case DECIMAL:
            // See Android bug #2626 (http://code.google.com/p/android/issues/detail?id=2626&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars)
            // Using SetKeyListener
            this.setHint(String.format(Locale.getDefault(), "%.1f", 0.0));
            this.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            this.setKeyListener(DigitsKeyListener.getInstance(false, true)); // should work but bug above means it will ALWAYS use a period.
            break;
    }
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:25,代码来源:DecimalEdit.java

示例6: onCreate

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);

    //Construct the preferences screen form XML config
    addPreferencesFromResource(R.xml.task_preferences);

    //Use the number keyboard when editing the time preference
    EditTextPreference timeDefault = (EditTextPreference)findPreference(getString(R.string.pref_default_time_from_now_key));
    timeDefault.getEditText().setKeyListener(DigitsKeyListener.getInstance());

    findPreference(this.getString(R.string.title_instructions)).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(getActivity(), IntroActivity.class);
            startActivity(intent);
            return false;
        }
    });
}
 
开发者ID:bowenchin,项目名称:RemindrApp-Android,代码行数:21,代码来源:PreferencesFragment.java

示例7: ExIntegerWidget

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
public ExIntegerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    mAnswer.setInputType(InputType.TYPE_NUMBER_FLAG_SIGNED);

    // only allows numbers and no periods
    mAnswer.setKeyListener(new DigitsKeyListener(true, false));

    // ints can only hold 2,147,483,648. we allow 999,999,999
    InputFilter[] fa = new InputFilter[1];
    fa[0] = new InputFilter.LengthFilter(9);
    mAnswer.setFilters(fa);

    Integer i = getIntegerAnswerValue();

    if (i != null) {
        mAnswer.setText(i.toString());
    }
}
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:20,代码来源:ExIntegerWidget.java

示例8: setDiscoveryDelay

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void setDiscoveryDelay() {

		final EditText input = new EditText(this);
		input.setHint(this.getString(R.string.hint_discoverydelay));
		input.setText(Integer.toString(nfc.getDiscoveryDelay()));
		input.setInputType(EditorInfo.TYPE_CLASS_NUMBER);
		input.setKeyListener(DigitsKeyListener.getInstance("01234567890"));
		input.setSingleLine(true);

		SetDelayHelper helper = new SetDelayHelper(nfc, input);

		new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)
				.setTitle(R.string.action_discoverydelay)
				.setMessage(R.string.lab_discoverydelay).setView(input)
				.setPositiveButton(R.string.action_ok, helper)
				.setNegativeButton(R.string.action_cancel, helper).show();
	}
 
开发者ID:sinpolib,项目名称:nfcspy,代码行数:18,代码来源:ActivityMain.java

示例9: getKeyListenerForType

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
/** gets the key listener by type */
private static KeyListener getKeyListenerForType(NumericType type) {
	switch (type) {
	case DIALPAD:
		return new DialerKeyListener();
	case INTEGER:
		return new DigitsKeyListener();
	case SIGNED:
		return new DigitsKeyListener(true, false);
	case DECIMAL:
		return new DigitsKeyListener(true, true);
	case NONE:
	default:
		return null;
	}
}
 
开发者ID:SahilArora92,项目名称:vit-04,代码行数:17,代码来源:TextEntryElement.java

示例10: init

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void init(AttributeSet attrs, int defStyle) {
    // @formatter:off
    final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PinputView, defStyle, 0);
    // @formatter:on

    setFocusableInTouchMode(false);
    setKeyListener(DigitsKeyListener.getInstance(false, false));

    mPinLen = a.getInt(R.styleable.PinputView_pinputview_len, 4);
    mCharPadding = (int) a.getDimension(R.styleable.PinputView_pinputview_characterPadding,
            getResources().getDimension(R.dimen.pinputview_default_char_padding));
    int foregroundColor = a.getColor(R.styleable.PinputView_pinputview_foregroundColor, Color.BLUE);
    int backgroundColor = a.getColor(R.styleable.PinputView_pinputview_backgroundColor, Color.GRAY);

    a.recycle();

    initDrawables(foregroundColor, backgroundColor);
    initFilters();
    initializeAnimator();
}
 
开发者ID:venmo,项目名称:android-pin,代码行数:21,代码来源:PinputView.java

示例11: getKeyListenerForType

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
/** gets the key listener by type */
protected static KeyListener getKeyListenerForType(NumericType type) {
	switch (type) {
	case DIALPAD:
		return new DialerKeyListener();
	case INTEGER:
		return new DigitsKeyListener();
	case SIGNED:
		return new DigitsKeyListener(true, false);
	case DECIMAL:
		return new DigitsKeyListener(true, true);
	case NONE:
	default:
		return null;
	}
}
 
开发者ID:SanaMobile,项目名称:sana.mobile,代码行数:17,代码来源:TextEntryElement.java

示例12: setEditable

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void setEditable(boolean editable) {
    if (editable) {
        etInput.setFocusable(true);
        etInput.setKeyListener(new DigitsKeyListener());
    } else {
        etInput.setFocusable(false);
        etInput.setKeyListener(null);
    }
}
 
开发者ID:Jmengfei,项目名称:AddSubUtils,代码行数:10,代码来源:AddSubUtils.java

示例13: DynamicTimeSet

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void DynamicTimeSet(final SharedPreferences sp) {
    int num = sp.getInt("DynamicReloadTime", 1000);
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View view = inflater.inflate(R.layout.dialog_text, null);
    AlertDialog.Builder set = new AlertDialog.Builder(getActivity());
    set.setTitle(R.string.xml_global_dynamicword_reload_time);
    final EditText et = (EditText) view.findViewById(R.id.dialog_text_edittext);
    et.setText(String.valueOf(num));
    et.setKeyListener(new DigitsKeyListener(false, true));
    set.setPositiveButton(R.string.done, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface d, int i) {
            String str = et.getText().toString();
            if (!str.isEmpty()) {
                int get = Integer.valueOf(str);
                if (get < 500) {
                    Toast.makeText(getActivity(), R.string.num_err, Toast.LENGTH_SHORT).show();
                } else {
                    sp.edit().putInt("DynamicReloadTime", get).apply();
                    Toast.makeText(getActivity(), R.string.restart_to_apply, Toast.LENGTH_LONG).show();
                }
            }
        }
    });
    set.setNegativeButton(R.string.cancel, null);
    set.setView(view);
    set.show();
}
 
开发者ID:XFY9326,项目名称:FloatText,代码行数:28,代码来源:GlobalSetActivity.java

示例14: setEditable

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void setEditable(boolean editable) {
    if (editable) {
        mCount.setFocusable(true);
        mCount.setKeyListener(new DigitsKeyListener());
    } else {
        mCount.setFocusable(false);
        mCount.setKeyListener(null);
    }
}
 
开发者ID:qinci,项目名称:NumberButton,代码行数:10,代码来源:NumberButton.java

示例15: initKeyboardButton

import android.text.method.DigitsKeyListener; //导入依赖的package包/类
private void initKeyboardButton(View view)
{
	final Button toggleKeyboardButton = view.findViewById(R.id.toggleKeyboard);
	if(toggleKeyboardButton != null)
	{
		toggleKeyboardButton.setText("abc");
		toggleKeyboardButton.setOnClickListener(v ->
		{
			View focus = getActivity().getCurrentFocus();
			if(focus != null && focus instanceof EditText)
			{
				EditText input = (EditText) focus;
				if ((input.getInputType() & InputType.TYPE_CLASS_NUMBER) != 0)
				{
					input.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
					toggleKeyboardButton.setText("123");
				} else
				{
					input.setInputType(InputType.TYPE_CLASS_NUMBER);
					input.setKeyListener(DigitsKeyListener.getInstance("0123456789.,- /"));
					toggleKeyboardButton.setText("abc");
				}

				InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
				imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
			}
		});
	}
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:30,代码来源:AddHousenumberForm.java


注:本文中的android.text.method.DigitsKeyListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。