问题
In my app, I have an EditText
, with a button to change the keyboard input type. The code:
ToggleCambiarTeclado.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (ToggleCambiarTeclado.isChecked()) {
tipoDeTecladoActual = InputType.TYPE_CLASS_NUMBER;
imagenTeclado.setImageDrawable(getResources().getDrawable(R.drawable.keyboard_numeric));
} else {
tipoDeTecladoActual = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
imagenTeclado.setImageDrawable(getResources().getDrawable(R.drawable.keyboard_querty));
}
editNumeroContador.setInputType(tipoDeTecladoActual);
}
});
It works perfectly in my phone...but my boss has a Samsung, and is not changing the keyboard type in his phone.
I have tried changing it to TYPE_TEXT_VARIATION_NORMAL
, TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
and YPE_CLASS_TEXT
, neither of them are working.
Anyone knows if this is a bug? Any known workaround?
Thank you.
EDIT:
Just realized my boss has TouchPal installed. If he changes the default keyboard to the standard it works perfectly...
回答1:
Later Samsung devices have SwiftKey keyboards built in. SwiftKey intentionally decided at some point to ignore Android's InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
.
A workaround is to use InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
, which is somewhat hacky, but an unfortunately common workaround.
XML variant: android:inputType="textVisiblePassword"
回答2:
Samsung's behave weirdly with most things. I've had this issue before and I seem to recall that changing the input type to email worked like a charm. Give it a try.
来源:https://stackoverflow.com/questions/33148168/inputtype-type-text-flag-no-suggestions-in-samsung