有没有一种工作方式类似于开始片段结果的方法? [英] Is there a method that works like start fragment for result?

查看:111
本文介绍了有没有一种工作方式类似于开始片段结果的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个覆盖一个片段。这是用于登录到服务。在手机应用程序,每一个我想在叠加显示的步骤是他们自己的屏幕和活动。分为3部分在登录过程中,每个都有自己的活动,被称为与startActivityForResult()。

I currently have a fragment in an overlay. This is for signing in to the service. In the phone app, each of the steps I want to show in the overlay are their own screens and activities. There are 3 parts of the sign-in process and each had their own activity that was called with startActivityForResult().

现在我想用碎片和覆盖做同样的事情。覆盖将显示相应于每个活动的片段。的问题是,这些片段被承载在蜂窝API中的活性。我能拿到第一个分片工作,但我需要startActivityForResult(),这是不可能的。有沿startFragmentForResult()的线,我可以启动新的片段,当它完成了它返回一个结果到previous片段东西?

Now I want to do the same thing using fragments and an overlay. The overlay will show a fragment corresponding to each activity. The problem is that these fragments are hosted in an activity in the Honeycomb API. I can get the first fragment working, but then I need to startActivityForResult(), which isn't possible. Is there something along the lines of startFragmentForResult() where I can kick off a new fragment and when it's done have it return a result to the previous fragment?

推荐答案

所有碎片,里面居住的活动。启动片段的结果并没有太大的意义,因为它总是容纳它的活动访问它,反之亦然。如果片段需要传递的结果,它可以访问它的活动,并设置其结果,并完成它。在一个单一的活动交换片段的情况下,很好的活动仍然是由两个片段访问,和所有的消息传递可以简单地通过该活动。

All of the Fragments live inside Activities. Starting a Fragment for a result doesn't make much sense, because the Activity that houses it always has access to it, and vice versa. If the Fragment needs to pass on a result, it can access its Activity and set its result and finish it. In the case of swapping Fragments in a single Activity, well the Activity is still accessible by both Fragments, and all your message passing can simply go through the Activity.

只要记住,你总是有一个片段,其活性之间的通信。启动并与结果整理是机制的沟通, - 该活动可以在任何必要的信息,然后委托给他们的片段

Just remember that you always have communication between a Fragment and its Activity. Starting for and finishing with a result is the mechanism for communication between Activities - The Activities can then delegate any necessary information to their Fragments.

这篇关于有没有一种工作方式类似于开始片段结果的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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