1

I am stuck with dictionary hints while entering password (or any other text field). 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?

Barmaley
  • 16,638
  • 18
  • 73
  • 146
  • I believe the keyboard/inputmethodservice that you are using is misbehaving. It can and should detect edittexts marked as password and prevent suggestions for them. Are you using the default system keyboard ? – Laurent' Sep 19 '11 at 12:03
  • Check this link http://stackoverflow.com/questions/1959576/turn-off-autosuggest-for-edittext. Similar problem. surprising answer. – Ron Sep 19 '11 at 14:15

3 Answers3

2

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

  • In some HTC Sense Devices(Not in all but in some specific), this doesn't seem to work. This is among the rarest. I have a HTC Wildfire and HTC Magic. I'm getting the normal android behavior in these ie.) no suggestions. – Anoop Chandrika HarisudhanNair Sep 20 '11 at 05:18
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"/>
theisenp
  • 8,639
  • 5
  • 39
  • 47
Mats Hofman
  • 7,060
  • 6
  • 33
  • 48
  • but this method just reformats input to asterisk alike symbols, r u sure that it will also suppress dictionary hints? – Barmaley Sep 15 '11 at 13:51
  • not sure but I think it will work and if not maybe in combination with `android:inputType="textPassword"` or the code you use now – Mats Hofman Sep 15 '11 at 14:15
  • Nope it doesn't work neither setting "android:password" nor setTransformationMethod – Barmaley Sep 18 '11 at 19:10
  • Maybe the answer of AndroidKid works and otherwise it might be the keyboard you are using, you should try it on a different phone / the emulator – Mats Hofman Sep 19 '11 at 13:15
-1

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);
William Melani
  • 4,270
  • 1
  • 21
  • 44
Yasser AKBBACH
  • 539
  • 5
  • 7