天天看點

android2.3 使用浏覽器位址欄 滑鼠移動時導緻輸入法消失問題

在浏覽器位址欄輸入網址時,會有個AutoCompleteTextView的清單。

持續輸入時,清單有時會消失。這時,移動滑鼠會導緻搜尋欄消失,進而導緻輸入法關閉。

這裡做了個workaround:

輸入時,強制AutoCompleteTextView的清單一直存在,這樣搜尋欄不消失,輸入法也不會關閉。

AutoCompleteTextView.java

@@ -1022,7 +1022,10 @@ public class AutoCompleteTextView extends EditText implements Filter.FilterListe
                 showDropDown();
             }
         } else if (!mDropDownAlwaysVisible) {
-            dismissDropDown();
+            if (hasFocus() && hasWindowFocus()) {
+                showDropDown();
+            }
+            // dismissDropDown();
         }
     }