android editText keyboard changed after setText()

2019-08-22 03:00发布

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

enter image description here

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

is there a way to prevent this happening?

2条回答
贼婆χ
2楼-- · 2019-08-22 03:23

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

查看更多
地球回转人心会变
3楼-- · 2019-08-22 03:35

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

查看更多
登录 后发表回答