本文整理汇总了Java中android.text.method.PasswordTransformationMethod.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java PasswordTransformationMethod.getInstance方法的具体用法?Java PasswordTransformationMethod.getInstance怎么用?Java PasswordTransformationMethod.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.method.PasswordTransformationMethod
的用法示例。
在下文中一共展示了PasswordTransformationMethod.getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCheckedChanged
import android.text.method.PasswordTransformationMethod; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
final TransformationMethod transformationMethod = isChecked ? null : PasswordTransformationMethod.getInstance();
for (final EditText passwordView : passwordViews)
passwordView.setTransformationMethod(transformationMethod);
}
示例2: onCheckedChanged
import android.text.method.PasswordTransformationMethod; //导入方法依赖的package包/类
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked)
{
final TransformationMethod transformationMethod = isChecked ? null : PasswordTransformationMethod.getInstance();
for (final EditText passwordView : passwordViews)
passwordView.setTransformationMethod(transformationMethod);
}
示例3: setInputType
import android.text.method.PasswordTransformationMethod; //导入方法依赖的package包/类
/**
* Set the type of the content with a constant as defined for
* {@link EditorInfo#inputType}. This will take care of changing
* the key listener, by calling {@link #setKeyListener(KeyListener)}, to
* match the given content type. If the given content type is
* {@link EditorInfo#TYPE_NULL} then a soft keyboard will
* not be displayed for this text view.
*
* @see #getInputType()
* @see #setRawInputType(int)
* @see android.text.InputType
* @attr ref android.R.styleable#TextView_inputType
*/
public void setInputType(int type) {
final boolean wasPassword = isPasswordInputType(mInputType);
final boolean wasVisiblePassword = isVisiblePasswordInputType(mInputType);
setInputType(type, false);
final boolean isPassword = isPasswordInputType(type);
final boolean isVisiblePassword = isVisiblePasswordInputType(type);
boolean forceUpdate = false;
if (isPassword) {
setTransformationMethod(PasswordTransformationMethod.getInstance());
setTypefaceByIndex(MONOSPACE, 0);
} else if (isVisiblePassword) {
if (mTransformation == PasswordTransformationMethod.getInstance()) {
forceUpdate = true;
}
setTypefaceByIndex(MONOSPACE, 0);
} else if (wasPassword || wasVisiblePassword) {
// not in password mode, clean up typeface and transformation
setTypefaceByIndex(-1, -1);
if (mTransformation == PasswordTransformationMethod.getInstance()) {
forceUpdate = true;
}
}
boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS
| EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) ==
(EditorInfo.TYPE_CLASS_TEXT
| EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
// We need to update the single line mode if it has changed or we
// were previously in password mode.
if (mSingleLine == multiLine || forceUpdate) {
// Change single line mode, but only change the transformation if
// we are not in password mode.
applySingleLine(!multiLine, !isPassword);
}
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) imm.restartInput(this);
}
示例4: updatePreference
import android.text.method.PasswordTransformationMethod; //导入方法依赖的package包/类
private void updatePreference(Preference preference) {
if (preference instanceof EditTextPreference) {
EditTextPreference listPreference = (EditTextPreference) preference;
if(listPreference.getEditText().getTransformationMethod() != PasswordTransformationMethod.getInstance() )
listPreference.setSummary(listPreference.getText());
}
}
示例5: setInputType
import android.text.method.PasswordTransformationMethod; //导入方法依赖的package包/类
/**
* Set the type of the content with a constant as defined for {@link EditorInfo#inputType}. This
* will take care of changing the key listener, by calling {@link #setKeyListener(KeyListener)},
* to match the given content type. If the given content type is {@link EditorInfo#TYPE_NULL}
* then a soft keyboard will not be displayed for this text view.
*
* Note that the maximum number of displayed lines (see {@link #setMaxLines(int)}) will be
* modified if you change the {@link EditorInfo#TYPE_TEXT_FLAG_MULTI_LINE} flag of the input
* type.
*
* @see #getInputType()
* @see #setRawInputType(int)
* @see android.text.InputType
* @attr ref android.R.styleable#TextView_inputType
*/
public void setInputType(int type) {
final boolean wasPassword = isPasswordInputType(getInputType());
final boolean wasVisiblePassword = isVisiblePasswordInputType(getInputType());
setInputType(type, false);
final boolean isPassword = isPasswordInputType(type);
final boolean isVisiblePassword = isVisiblePasswordInputType(type);
boolean forceUpdate = false;
if (isPassword) {
setTransformationMethod(PasswordTransformationMethod.getInstance());
setTypefaceFromAttrs(null /* fontFamily */, MONOSPACE, 0);
} else if (isVisiblePassword) {
if (mTransformation == PasswordTransformationMethod.getInstance()) {
forceUpdate = true;
}
setTypefaceFromAttrs(null /* fontFamily */, MONOSPACE, 0);
} else if (wasPassword || wasVisiblePassword) {
// not in password mode, clean up typeface and transformation
setTypefaceFromAttrs(null /* fontFamily */, -1, -1);
if (mTransformation == PasswordTransformationMethod.getInstance()) {
forceUpdate = true;
}
}
boolean singleLine = !isMultilineInputType(type);
// We need to update the single line mode if it has changed or we
// were previously in password mode.
if (mSingleLine != singleLine || forceUpdate) {
// Change single line mode, but only change the transformation if
// we are not in password mode.
applySingleLine(singleLine, !isPassword, true);
}
if (!isSuggestionsEnabled()) {
mText = removeSuggestionSpans(mText);
}
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) imm.restartInput(this);
}