我需要在這個第二眼。我遵循基本指令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。
不確定是否刪除此問題。的確,實際問題比問題本身更普遍和更基本,所以它有點誤導。另一方面,其他人可能會陷入這種情況。 –