How to suppress dictionary hints while entering text?
I am stuck with dictionary hints while entering password (or any other text fiel开发者_高级运维d). I am doing it in this way:
editText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_PASSWORD |
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
But anyway when user selects keyboard predictions as "on" - during password entering it shows dictionary hints, which is stupid for passwords!
What I'm doing wrong?
textNoSuggestions 0x00080001
Can be combined with text and its variations to indicate that the IME should not show any dictionary-based word suggestions. Corresponds to TYPE_TEXT_FLAG_NO_SUGGESTIONS.
More Info Here: http://developer.android.com/reference/android/R.styleable.html#AutoCompleteTextView_inputType
Use the IME Options for the Edit text.
<EditText android:id="@+id/edtPass"
android:inputType="textPassword"
android:imeOptions="textNoSuggestions"/>
More about Input Types: http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputMethod
Also Do take a Look at here http://groups.google.com/group/android-developers/browse_thread/thread/d3c055137498bbc9?pli=1
You have to use the setTransformationMethod()
method like this:
editText.setTransformationMode(new PasswordTransformationMethod());
android.text.method.TransformationMethod
Or whats also possible is to set the android:password
value to true
in your layout XML like this:
<EditText
...
android:password="true"/>
Check it out!
reference: https://developer.android.com/reference/android/R.styleable#AutoCompleteTextView_inputType
1: https://i.stack.imgur.com/ULX2a.png See the picture
XML:
android:inputType="textVisiblePassword"/>
JAVA
editText.setRawInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
精彩评论