与片段设计中的应用 [英] Design Application with fragments

查看:82
本文介绍了与片段设计中的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始开发基于片段一个新的应用程序。我想实现的是类似的活动组的东西。在谈话的片段我在想,开始创建FragmentActivity(称之为TabActivity)那会管理不同的标签。每片是一个ListFragment的化合物和我需要基于用户输入来启动不同片段。我的想法让执行TabActivity不同CallBackListener(一个用于ListFragment),并根据回叫的呼叫,创建一个新片段。可能是这是一个正确的解决方案?我发现文档有点混乱,有点沮丧...

I am starting developing a new application based on fragments. What I want to achieve is something similar to an activity group. Talking in fragments I was thinking to start create a FragmentActivity (call it TabActivity) that would manages different tabs. Every tab is compound of a ListFragment and I need to start different fragment based on the user input. My idea lets implement the TabActivity different CallBackListener (one for ListFragment) and, based on the call back called, create a new fragment. Could be this a correct solution? I found the documentation a bit confusing and a little frustrating...

TabActivity:
     ListFragment1: fragment1 -> fragment2 -> fragment3
     ListFragment2: fragment4 -> fragment5 -> fragment6
     ListFragment3: fragment7 -> fragment8 -> fragment9

在此先感谢

编辑:每个ListFragment共享相同的容器,​​以显示其内容。

every ListFragment shares the same container in order to show their content

推荐答案

我已经做了类似的东西在那里我有一个活动,这只是什么片段将是可见的在任何给定的时间控制器/容器。

I have done something similar where I have an Activity that is just a controller/container for what Fragments will be viewable at any given time.

我有接受足够的信息,以确定片段是要显示的活动的方法,以及该包需要来填充片段。然后碎片可以告诉它需要改变了活动或使用该界面添加新的片段。

I have a method on the Activity that accepts enough information to determine what Fragment is to be shown, and the bundle it needs to populate the Fragment. Fragments can then tell the activity that it needs to change out, or add the new Fragment using that interface.

我的特定情况下实际使用相同的机制来控制在父活动的布局几个不同的片段容器的内容。

My particular case actually uses the same mechanism to control the content of several different "fragment containers" in the layout of the parent Activity.

这篇关于与片段设计中的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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