]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Hide virtual keyboard if searchView text was changed programatically.
authorKteby <sergeyleuhinintegral@gmail.com>
Thu, 28 Jan 2016 07:03:34 +0000 (10:03 +0300)
committerKteby <sergeyleuhinintegral@gmail.com>
Thu, 28 Jan 2016 07:03:34 +0000 (10:03 +0300)
src/com/hughes/android/dictionary/DictionaryActivity.java

index bd45672730ce08c79e90f0ac083c3f2e1218e574..c8d99e4f60328e4b440b1c9d280b08b9828b91b7 100644 (file)
@@ -638,6 +638,13 @@ public class DictionaryActivity extends ActionBarActivity {
         }
     }
 
+    private void hideKeyboard() {
+        Log.d(LOG, "Hide soft keyboard.");
+        searchView.clearFocus();
+        InputMethodManager manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+        manager.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
+    }
+
     void updateLangButton() {
         final LanguageResources languageResources =
                 DictionaryApplication.isoCodeToResources.get(index.shortName);
@@ -1006,7 +1013,7 @@ public class DictionaryActivity extends ActionBarActivity {
         getListView().requestFocus();
 
         // Visual indication that a new keystroke will clear the search text.
-        // Doesn't seem to work unless earchText has focus.
+        // Doesn't seem to work unless searchText has focus.
         // searchView.selectAll();
     }
 
@@ -1109,6 +1116,9 @@ public class DictionaryActivity extends ActionBarActivity {
         searchView.setIconifiedByDefault(text.length() > 0);
         searchView.setIconified(false);
 
+        // We don't want to show virtual keyboard when we're changing searchView text programatically:
+        hideKeyboard();
+
         if (triggerSearch) {
             onQueryTextListener.onQueryTextChange(text);
         }