當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。