@@ -151,6 +151,14 @@ public void run() {
151151 }
152152 };
153153
154+ private Runnable mReleaseCursorRunnable = new Runnable () {
155+ public void run () {
156+ if (mSuggestionsAdapter != null && mSuggestionsAdapter instanceof SuggestionsAdapter ) {
157+ mSuggestionsAdapter .changeCursor (null );
158+ }
159+ }
160+ };
161+
154162 // For voice searching
155163 private final Intent mVoiceWebSearchIntent ;
156164 private final Intent mVoiceAppSearchIntent ;
@@ -759,6 +767,7 @@ private void updateFocusedState() {
759767 @ Override
760768 protected void onDetachedFromWindow () {
761769 removeCallbacks (mUpdateDrawableStateRunnable );
770+ post (mReleaseCursorRunnable );
762771 super .onDetachedFromWindow ();
763772 }
764773
@@ -1028,7 +1037,9 @@ private void updateSearchAutoComplete() {
10281037 }
10291038 }
10301039 mQueryTextView .setInputType (inputType );
1031-
1040+ if (mSuggestionsAdapter != null ) {
1041+ mSuggestionsAdapter .changeCursor (null );
1042+ }
10321043 // attach the suggestions adapter, if suggestions are available
10331044 // The existence of a suggestions authority is the proxy for "suggestions available here"
10341045 if (mSearchable .getSuggestAuthority () != null ) {
@@ -1177,7 +1188,6 @@ public void onWindowFocusChanged(boolean hasWindowFocus) {
11771188 public void onActionViewCollapsed () {
11781189 clearFocus ();
11791190 updateViewsVisibility (true );
1180- mQueryTextView .setText ("" );
11811191 mQueryTextView .setImeOptions (mCollapsedImeOptions );
11821192 mExpandedInActionView = false ;
11831193 }
@@ -1192,6 +1202,7 @@ public void onActionViewExpanded() {
11921202 mExpandedInActionView = true ;
11931203 mCollapsedImeOptions = mQueryTextView .getImeOptions ();
11941204 mQueryTextView .setImeOptions (mCollapsedImeOptions | EditorInfo .IME_FLAG_NO_FULLSCREEN );
1205+ mQueryTextView .setText ("" );
11951206 setIconified (false );
11961207 }
11971208
0 commit comments