0

I have a SearchView in the ActionBar. When it is selected, the keyboard shows up.

However, when I touch or interact with anything else on the screen, including selecting list items and doing fragment transactions, the keyboard stays up, and the SearchView keeps focus.

I've tried setOnTouchListener() for the fragment, and listening to focus changes and calling the usual keyboard retraction code (link), but nothing works.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item android:id="@+id/action_store_search"
        android:icon="@android:drawable/ic_menu_search"
        app:showAsAction="always"
        app:actionViewClass="com.example.views.CustomSearchView"
        android:title="@string/header_search_loc"
        android:orderInCategory="1"
        android:menuCategory="secondary" />

</menu>
Community
  • 1
  • 1
Yervant
  • 225
  • 2
  • 8

1 Answers1

0

Just curious, what other views are in your activity or fragment where this SearchView resides? Are they able to receive focus?

Does the onActionViewCollapsed() method ever get called when you are supposed to lose focus on the SearchView?

I would try changing

app:showAsAction="always"

to

android:showAsAction="collapseActionView|ifRoom"

and see if the same behavior persists.

airowe
  • 746
  • 2
  • 8
  • 25