0

I'm using the android:windowSoftInputMode="stateVisible" command for drawing keyboard at the beginning of the Activity and it works just as I want it to work with 2 slight problems - swype-typing is enabled and so is the word prediction and I want to prevent it from happening. I thought maybe setting keyboard in passwordText input mode may solve the problem but I cannot find anywhere how to do it. Is there any method that will allow me to show keyboard in passwordText mode on start of the Activity?

Also I should add that I'm looking for the way of doing that in such a way, that the keybord won't show when app is ran on device with physical keyboard (that's why I used XML declaration in the first place).

qiubit
  • 4,708
  • 6
  • 23
  • 37

2 Answers2

1

Add the following to your Edittext in xml:

android:inputType="textPassword|textNoSuggestions"

or in code:

edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS|InputType.TYPE_TEXT_VARIATION_PASSWORD);

hrishitiwari
  • 634
  • 7
  • 15
  • I don't have any EditTexts, I'm handling keyboard input in Activity, and as I said I used `android:windowSoftInputMode="stateVisible"` in AndroidManifest in order for keyboard to appear the problem is it allows swyping and shows suggestions and I need to change it without using any EditTexts. (To handle keyboard input I'm using `onKeyDown()` and `onKeyUp()` methods in Activity) – qiubit Aug 15 '14 at 20:37
0

Well, for the first question, AFAIK you set the textfield to password mode, not the keyboard, like this:

<EditText
android:id="@+id/password"
android:hint="@string/password_hint"
android:inputType="textPassword"
... />  

More info here: https://developer.android.com/training/keyboard-input/style.html

Now, about preventing the keyboard from appearing on a device with physical keyboard, I recomend you check this answer:

How do I prevent the software keyboard from popping up?

Community
  • 1
  • 1
paulonogueira
  • 2,684
  • 2
  • 18
  • 31
  • the thing is I don't have any EditText fields, as I'm handling entire keyboard input from the activity and I want it to stay that way. – qiubit Aug 15 '14 at 20:34