事实上,我有一个我打电话的活动
onSearchRequested()
然后,我在同一个活动中使用此函数来获取搜索字符串:
// Get the intent,verify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.query); }
问题是下一个:当我点击搜索按钮时,我正在打开一个新活动,我想保持相同并进行一些搜索.因此,我的目标是在单击搜索按钮时避免新活动打开.
谢谢.
解决方法 解决方案包括重用开发人员示例 http://developer.android.com/guide/topics/search/search-dialog.html重要的是创建2个活动,一个用于搜索,另一个用于显示结果.
在清单中,使用以下代码:
<application ... ><!-- this is the searchable activity; it performs searches --><activity androID:name=".SearchableActivity" > <intent-filter> <action androID:name="androID.intent.action.SEARCH" /> </intent-filter> <Meta-data androID:name="androID.app.searchable" androID:resource="@xml/searchable"/></activity><!-- this activity enables the search dialog to initiate searches in the SearchableActivity --><activity androID:name=".OtherActivity" ... > <!-- enable the search dialog to send searches to SearchableActivity --> <Meta-data androID:name="androID.app.default_searchable" androID:value=".SearchableActivity" /></activity>...总结
以上是内存溢出为你收集整理的android – 搜索界面在搜索时打开一个新的Activity全部内容,希望文章能够帮你解决android – 搜索界面在搜索时打开一个新的Activity所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)