]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryActivity.java
Merge pull request #26 from Kteby/master
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryActivity.java
index e0290b065eb1e8cc057e5091c6cdc170494df368..f8cca586e94f6e6cb7cb27a01a184a7570a84bb4 100644 (file)
@@ -640,6 +640,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);
@@ -1025,7 +1032,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();
     }
 
@@ -1128,6 +1135,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);
         }