从搜索查看更改片段提交又名级联下来backstack [英] Changing fragment from SearchView submit aka Cascading down the backstack

查看:104
本文介绍了从搜索查看更改片段提交又名级联下来backstack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为了当前使用的是搜索查看对象给出建议的输入我的应用程序的功能。

I'm currently using a SearchView object in order to give my application functionality for suggested input.

这个小部件然而,提交时,使用了意图过滤器来开始你的搜索。当我的应用程序在手机上运行,​​因为我想要做的是推出一个搜索结果活动来显示响应这是伟大的。 然而在平板电脑上,我希望它加载在位于电流活性的片段我的搜索结果

This widget however, when submitted, uses an intent-filter to to initiate your searching. This is great when my application is run on a phone because what I want to do is launch a Search Results Activity to display the response. However on a tablet I want it to load my search results in a Fragment located in the current Activity!

我想我的应用程序尽可能统一(在电话/标签之间的交叉方面),因此,而不是覆盖提交行为提出的在这个答案我想一个新的活动启动哪些路由需要的地方去搜索词。在手机上的结果活动,在选项卡上,我想对搜索关键词传递给previous活动。

I want my app to be as unified as possible (In terms of crossover between phone/tab) so instead of overwriting the submit behaviour as suggested in this answer I would like a new activity to be started which routes the search term where it needs to go. On a phone to the results Activity, on a tab I would like to pass the searchTerm to the previous Activity.

所以我想问一下 - 你可以在backstack信息传递到previous活动

So I would like to ask - Can you pass information to a previous Activity in the backstack?

推荐答案

我会建议你有你的SearchCatchingActivity充当的路由的活动。它可以捕获查询,并将其(带结果片段或单结果片段的单一界面无论是双窗格)传递给需要的活动。路由到下一个活动时,使之成为该实例的默认活动中使用 FLAG_ACTIVITY_CLEAR_TOP 意图标志。记得拨打完成()您的路由活动从backstack删除它。

I would suggest you having your SearchCatchingActivity acting as a routing Activity. It can catch query and pass it to the required Activity (be it dual pane with result fragment or a single pane with single result fragment). Use FLAG_ACTIVITY_CLEAR_TOP intent flag when routing to the next Activity so that it becomes the default Activity of that instance. Remember to call finish() on your routing activity to remove it from the backstack as well.

这篇关于从搜索查看更改片段提交又名级联下来backstack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆