Android: Multiline & No autosuggest in EditText

2019-02-16 21:39发布

Is it possible to have an EditText that allows multilines and doesn't show the suggestions? I tried with this code:

android:inputType="textFilter|textMultiLine"

Which I saw in this question, but it didn't work for me. If I try to use both at the same time, the EditText supports multiline, but the suggestions appear. Separately, they work properly.

Is this a bug in the SDK? Or maybe it is not possible to combine them?

Thanks!

7条回答
劫难
2楼-- · 2019-02-16 21:53
android:inputType="textVisiblePassword"

It is working on android 2.3.x and above.

查看更多
We Are One
3楼-- · 2019-02-16 21:57

Works for me

android:inputType="textVisiblePassword|textMultiLine"
查看更多
成全新的幸福
4楼-- · 2019-02-16 22:02

you can also use android:SingleLine="false" to use multiline for an EditText

查看更多
甜甜的少女心
5楼-- · 2019-02-16 22:02

A bit later than the others & the answer has been accepted, but after some testing on various devices, some keyboards ignore textFilter and textNoSuggestion, the only way that I've found to guarantee no keyboard is using textVisiblePassword

If you want it on a multi-line, you can use:

android:inputType="textVisiblePassword|textMultiLine"

Note that it has little to do with the API level, but more to do with the keyboard installed - the default Samsung keyboard on slightly older devices, SwiftKey & TouchPal definitely ignore textFilter & textNoSuggestion

I hope this helps someone else in the future

查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-02-16 22:04

This is supposed to do what you want:

android:inputType="textFilter|textMultiLine|textNoSuggestions"

Although I haven't tried it myself. "textNoSuggestions" is only available since API 5.

查看更多
Melony?
7楼-- · 2019-02-16 22:05

Warning: it looks like this is API version dependent.

textFilter option alone works for me on a tab running 3.1 (no suggestion when typing) but it does not work on a smartphone running 2.2 (still suggest when typing).

On 2.2 I use :

android:inputType="textVisiblePassword"

Annoying none the less if we have to check against all different API...

查看更多
登录 后发表回答