예제 #1
0
 @Override
 public boolean onKeyPreIme(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     // special case for the back key, we do not even try to send it
     // to the drop down list but instead, consume it immediately
     if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
       KeyEvent.DispatcherState state = getKeyDispatcherState();
       if (state != null) {
         state.startTracking(event, this);
       }
       return true;
     } else if (event.getAction() == KeyEvent.ACTION_UP) {
       KeyEvent.DispatcherState state = getKeyDispatcherState();
       if (state != null) {
         state.handleUpEvent(event);
       }
       if (event.isTracking() && !event.isCanceled()) {
         mSearchView.clearFocus();
         mSearchView.setImeVisibility(false);
         return true;
       }
     }
   }
   return super.onKeyPreIme(keyCode, event);
 }
예제 #2
0
    /**
     * We override this method to be sure and show the soft keyboard if appropriate when the
     * TextView has focus.
     */
    @Override
    public void onWindowFocusChanged(boolean hasWindowFocus) {
      super.onWindowFocusChanged(hasWindowFocus);

      if (hasWindowFocus && mSearchView.hasFocus() && getVisibility() == VISIBLE) {
        InputMethodManager inputManager =
            (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.showSoftInput(this, 0);
        // If in landscape mode, then make sure that
        // the ime is in front of the dropdown.
        if (isLandscapeMode(getContext())) {
          ensureImeVisible(true);
        }
      }
    }
예제 #3
0
 @Override
 protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
   super.onFocusChanged(focused, direction, previouslyFocusedRect);
   mSearchView.onTextFocusChanged();
 }