android editText keyboard changed after setText()

2019-08-22 02:35发布

问题:

If I want to enter a message into an editText, I enter some digits and my keyboard looks like that:

but after I add some text from code by clicking the button (et.setText(et.getText().toString() + " " + "abc")), keyboard changes to:

is there a way to prevent this happening?

回答1:

I've used editable.append instead of et.setText() and this works



回答2:

You should set input type in your EditText (for example by using "android:inputType" in xml file containing the layout).

See: http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType