在一个AndroidManifest.xml中两个searchable.xml活动 [英] Two searchable.xml activities in one AndroidManifest.xml
问题描述
我有一个Android应用程序具有用于从浏览下载RSS文章和图片的几个不同的活动。
I have an Android app which has a few different activities for browsing articles and images downloaded from RSS.
我希望能够提供挂钩的搜索按钮,搜索对话框,使用一个 searchable.xml
文件。我已经成功地与一个搜索做到这一点,使用:
I'd like to be able to offer to hook up the search button to the Search dialog, using the a searchable.xml
file. I've managed to do this with one search, using:
<activity android:name=".search.SearchResultsActivity"
android:label="@string/search_results_activity_title" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable_articles"/>
</activity>
和&lt;应用/&GT;
<meta-data android:name="android.app.default_searchable"
android:value=".search.SearchResultsActivity" />
我现在可以从任何活动启动搜索对话框,并启动 SearchResultsActivity
。
我现在想能够搜索图像时用户是 ImageListActivity
,使用 searchable_images.xml
,并使用默认的其他地方。
I would now like to be able to search for images when the user is an ImageListActivity
, using a searchable_images.xml
, and use the default everywhere else.
我有一个 SearchResultsImageActivity
,其中包括以下的元数据元素,并用相同的元素在 ImageListActivity
I have a SearchResultsImageActivity
which includes the following meta-data element, and used the same element in the ImageListActivity
.
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable_images"/>
在pressing在搜索按钮 ImageListActivity
,我从 searchable_articles.xml
默认搜索。
On pressing the search button in the ImageListActivity
, I get the default search from searchable_articles.xml
.
如果我修改 default_searchable
到 SearchResultsImageActivity
,图像搜索总是启动,文章搜索是永远推出。
If I change the default_searchable
to SearchResultsImageActivity
, the image search is always launched, and the article search is never launched.
如果我完全删除 default_searchable
的元数据元素,并添加搜索
的元数据仅供评选活动中,没有搜索启动。
If I remove the default_searchable
meta-data element altogether, and add searchable
meta-data only selected activities, no search is launched.
我相当肯定这应该是可能的,但我不知道我做错了。
I'm fairly sure this should be possible, but I don't know what I'm doing wrong.
推荐答案
在你的清单
文件更新 ImageListActivity
活动标签
In your Manifest
file update the ImageListActivity
activity tag
<activity
android:name=".ImageListActivity"
...
<meta-data
android:name="android.app.default_searchable"
android:value=".SearchResultsImageActivity" />
</activity>
所以,当你将触发 ImageListActivity
本地搜索它会调用 SearchResultsImageActivity
键,默认的为别人着想。
So when you will trigger native search in ImageListActivity
it will invoke the SearchResultsImageActivity
and default one for others.
假设 SearchResultsImageActivity
是搜索
。
这篇关于在一个AndroidManifest.xml中两个searchable.xml活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!