searchManager.getSearchableInfo(getComponentName()) returns null

微笑、不失礼 提交于 2019-12-01 03:33:02

Add it to the activity where you've put your SearchView

<meta-data
    android:name="android.app.default_searchable"
    android:value=".activity_that_handles_the_search" />

<intent-filter>
    <action android:name="android.intent.action.SEARCH" />
</intent-filter>

In my case the problem was my mistake during integration with ActionBarSherlock. In this case android:actionViewClass should be com.actionbarsherlock.widget.SearchView instead of android.widget.SearchView. I know this sounds dumb, but I spent 20 minutes trying to figure out why searchView is null in my code that is similar to yours.

Mandeep Singh

Replace:

android:actionViewClass="android.widget.SearchView"

With:

app:actionViewClass="android.widget.SearchView"

Because app is often used if you are using support library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!