Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutocompleteTextView: on "NEXT" highlight next TextView, on "DONE", make keyboard disappear

I have two AutocompleTextViews and I want to switch to the next if the user presses "NEXT", and make the virtual keyboard disappear when he hits "DONE" at the second AutocompleTextView. So far, the buttons "NEXT"/"DONE" do nothing at all.... Unfortunately I found no resources addressing this problem.

Any suggestions? thx

EDIT: Just want to add that this was asked when Android was on version 2.3 or something like that.

like image 324
MJB Avatar asked Apr 30 '10 20:04

MJB


2 Answers

I ran into this problem and fixed it by setting the imeOptions on the AutocompleteTextView to actionNext.

Example:

<AutoCompleteTextView     android:id="@+id/dialog_product_name"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_weight="1"     android:singleLine="true"     android:completionThreshold="1"     android:imeOptions="actionNext"     /> 
like image 196
cebru Avatar answered Sep 21 '22 12:09

cebru


I found this solution for the "NEXT" problem: in your View source code write something like this

@Override public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) {     if (firstAutoComplete.hasFocus()) {     // sends focus to another field (user pressed "Next")     otherText.requestFocus();     return true;     }     else if (secondAutoComplete.hasFocus()) {             // sends focus to another field (user pressed "Next")     anotherText.requestFocus();     return true;     } } return false; } 

It seems to be an old Android http://code.google.com/p/android/issues/detail?id=4208. Here I found my solution: http://groups.google.com/group/android-developers/browse_thread/thread/e53e40bfe255ecaf.

like image 39
Paolo Avatar answered Sep 22 '22 12:09

Paolo