本文整理汇总了Java中android.text.InputType.TYPE_NUMBER_FLAG_DECIMAL属性的典型用法代码示例。如果您正苦于以下问题:Java InputType.TYPE_NUMBER_FLAG_DECIMAL属性的具体用法?Java InputType.TYPE_NUMBER_FLAG_DECIMAL怎么用?Java InputType.TYPE_NUMBER_FLAG_DECIMAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.InputType
的用法示例。
在下文中一共展示了InputType.TYPE_NUMBER_FLAG_DECIMAL属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
private int getType(EditType editType) {
int type;
switch (editType) {
case phone:
type = InputType.TYPE_CLASS_PHONE;
break;
case number:
type = InputType.TYPE_CLASS_NUMBER;
break;
case numberDecimal:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
break;
case textPassword:
type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
break;
case numberPassword:
type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
break;
default:
type = InputType.TYPE_CLASS_TEXT;
}
return type;
}
示例2: setInputType
@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);
}
}
示例3: updateInputMethod
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()));
}
}