private boolean onSuggestionsKey ( View v , int keyCode , KeyEvent event ) { // guard against possible race conditions (late arrival after dismiss) if ( mSearchable == null ) { return false ; } if ( mSuggestionsAdapter == null ) { return false ; } if ( event . getAction ( ) == KeyEvent . ACTION_DOWN && KeyEventCompat . hasNoModifiers ( event ) ) { // First, check for enter or search (both of which we'll treat as a // "click") if ( keyCode == KeyEvent . KEYCODE_ENTER || keyCode == KeyEvent . KEYCODE_SEARCH || keyCode == KeyEvent . KEYCODE_TAB ) { int position = mQueryTextView . getListSelection ( ) ; return onItemClicked ( position , KeyEvent . KEYCODE_UNKNOWN , null ) ; } // Next, check for left/right moves, which we use to "return" the // user to the edit view if ( keyCode == KeyEvent . KEYCODE_DPAD_LEFT || keyCode == KeyEvent . KEYCODE_DPAD_RIGHT ) { // give "focus" to text editor, with cursor at the beginning if // left key, at end if right key // TODO: Reverse left/right for right-to-left languages, e.g. // Arabic int selPoint = ( keyCode == KeyEvent . KEYCODE_DPAD_LEFT ) ? 0 : mQueryTextView . length ( ) ; mQueryTextView . setSelection ( selPoint ) ; mQueryTextView . setListSelection ( 0 ) ; mQueryTextView . clearListSelection ( ) ; ensureImeVisible ( mQueryTextView , true ) ; return true ; } // Next, check for an "up and out" move if ( keyCode == KeyEvent . KEYCODE_DPAD_UP && 0 == mQueryTextView . getListSelection ( ) ) { // TODO: restoreUserQuery(); // let ACTV complete the move return false ; } // Next, check for an "action key" // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode); // TODO if ((actionKey != null) // TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey // TODO .getSuggestActionMsgColumn() != null))) { // TODO // launch suggestion using action key column // TODO int position = mQueryTextView.getListSelection(); // TODO if (position != ListView.INVALID_POSITION) { // TODO Cursor c = mSuggestionsAdapter.getCursor(); // TODO if (c.moveToPosition(position)) { // TODO final String actionMsg = getActionKeyMessage(c, actionKey); // TODO if (actionMsg != null && (actionMsg.length() > 0)) { // TODO return onItemClicked(position, keyCode, actionMsg); // TODO } // TODO } // TODO } // TODO } } return false ; }
React to the user typing while in the suggestions list . First check for action keys . If not handled try refocusing regular characters into the EditText .