通过活动之​​间的片段 [英] Pass fragments between activities

查看:83
本文介绍了通过活动之​​间的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打,可支持纵向和横向的应用程序。布局有两个窗格,左边是选项和右侧示出了结果。当选择一个选项右侧窗格中显示它。但是,对于人像没有足够的空间,因此需要一个独立的活动。每个选项产生不同类型的片段,所以我并不想为每个选项的活动时,所有的活动之间的变化是被添加了什么片段那里。我想从主要活动传递一个片段到新的,我会怎么做呢?


解决方案

  

我想从主要活动传递一个片段到新的,我会怎么做呢?


您不会。至多,你会关注@核糖的答案 - 通过一个标记为活动通过一个额外的指出哪些片段设置为创建

I want to make an application that can support portrait and landscape. The layout has two panes, on the left is the options and the right shows the result. When an option is selected the right pane shows it. But for portrait there is not enough room, so a separate activity is needed. Each option produces a different type of fragment, so I don't want to make an activity for each option when all that changes between activities is what fragment is being added there. I want to pass a fragment from the main activity to the new one, how would I do this?

解决方案

I want to pass a fragment from the main activity to the new one, how would I do this?

You wouldn't. At most, you would follow @Ribose's answer -- pass a flag into the activity via an extra to indicate what set of fragments to create.

这篇关于通过活动之​​间的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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