本文整理汇总了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 ) );
}
示例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());
}
示例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);
}
}
示例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()));
}
}
示例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;
}
}
示例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;
}
});
}
示例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());
}
}
示例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();
}
示例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;
}
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
});
}
}