Search widget on action bar doesn't trigger my search activity

前端 未结 3 428
感情败类
感情败类 2020-12-13 19:38

I\'m developing search widget interface based on official tutorial: http://developer.android.com/guide/topics/search/search-dialog.html

Problem: My

相关标签:
3条回答
  • 2020-12-13 20:08

    If "xml/searchable.xml" file is not correctly formatted (things such as "searchable" tag not in all lower case), there is no error message returned during execution and the "SearchableActivity" doesn't get invoked.

    0 讨论(0)
  • 2020-12-13 20:24

    Problem solved: the tutorial seems to missing one important part: <meta-data android:name="android.app.default_searchable" android:value=".MySearchActivityName" /> has to be added inside <application> tags in manifest to get the search widget working correctly.

    EDIT- Also a hint to solving a problem when the actionbar search is not triggered on data posting (no error given whatsoever and documentations hasn't got a word about this limitation): in searchable.xml file android:hint and android:label attributes MUST be references to strings in strings.xml. Source

    0 讨论(0)
  • 2020-12-13 20:33

    You should override onOptionsItemSelected and probably onSearchRequested in your activity.

    0 讨论(0)
提交回复
热议问题