我需要在这个第二眼。我遵循基本指令here在我正在处理的应用程序中设置搜索,但我无法使用设备搜索按钮和搜索操作在操作栏上显示搜索对话框。Android搜索对话框没有打开按钮/动作按
就操作栏而言,我已经确认onSearchRequested在按下动作时被调用。这些文件中引用的任何资源都存在 - 应用程序运行时没有错误。
我searchable.xml:
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_label"
android:hint="@string/search_hint" >
</searchable>
我的搜索处理活动的在AndroidManifest.xml活动定义:
<activity android:name=".SearchActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
对于每一个在我想的搜索活动,我已经加入:
<meta-data android:name="android.app.default_searchable"
android:value=".SearchActivity" />
当我按上面提到的任何按钮时,没有任何反应。 logcat中也没有任何反应。由于onSearchRequested被调用,我怀疑我的配置有问题,但我一直无法找到它。
如果可能很重要,我可以指出我的SearchActivity扩展了RoboFragmentActivity。
不确定是否删除此问题。的确,实际问题比问题本身更普遍和更基本,所以它有点误导。另一方面,其他人可能会陷入这种情况。 –