I have One AutocompleTextView and I want to make the virtual keyboard disappear when he hits "DONE" at the AutocompleTextView. So far, the buttons "NEXT"/"DONE" do nothing at all. Any ideas?
Asked
Active
Viewed 8,373 times
16
-
Can you post the code/xml declaring the AutoCompleteTextView. – Robby Pond Jun 24 '10 at 12:36
-
– Pinki Jun 25 '10 at 05:21
5 Answers
18
Add this Property to your AutoCompleteTextView
in xml
:
android:imeOptions="actionDone"

Bhavin Nattar
- 3,189
- 2
- 22
- 30

fasttrack
- 181
- 1
- 4
-
android:inputType="text" was also required in order for it to work properly for me – brassmookie Sep 21 '22 at 20:53
12
The following works for all the Views which support imeOptions; for instance EditText
, TextView
, AutocompleteTextView
, etc.
In your xml:
<autocompleteTextView
inputType = "text"
imeOptions = "actionDone"
/>
In Java:
autocomplete = (AutoCompleteTextView) issueDetailView.findViewById(R.id.yourId);
autocomplete.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId== EditorInfo.IME_ACTION_DONE) {
//do Whatever you Want to do
}
return true;
}
});

Rahul Jain
- 121
- 1
- 4
-
1problem with this is that i cannot get it to have more then one line of text, both `android:minLines` and `android:lines` dont work with this solution for me. – Kostyantin2216 Apr 14 '17 at 13:14
-
I'd like to point out that inputType = "text" is necessary for imeOption to work. I didn't have it and was seing the return button – jack_the_beast Mar 21 '22 at 15:13
8
Just add the following on yours XML layout file:
android:imeOptions="actionDone"
android:singleLine="true"

Vadim Kotov
- 8,084
- 8
- 48
- 62

Frank021
- 121
- 2
- 11
-
I think this may be a bug in Android, something to do with backward compatibility or even maybe device specific. IME options won't work without single line (depreciated), even when max-lines is specified. – micwallace Oct 30 '16 at 13:05
-
-
by default autocompletetextview singleline property remains false that's why when just put android:imeOptions="actionDone" the soft keyboard doesn't work – Ayan Bhattacharjee May 12 '21 at 06:22
1
In my case android:imeOptions
only works if i set android:inputType
which is
android:inputType="textAutoComplete" android:imeOptions="actionDone"

Sourav Anand
- 41
- 2
- 3