Android中的动态片段 [英] Dynamic Fragments in Android

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

问题描述

是否可以动态创建片段以生成包含多个片段的布局,例如在网格视图中.目前,如果我的布局中有固定数量的片段,我将只能加载多个片段.

Is it possible to create fragments dynamically to generate a layout containing multiple fragments something like in a grid view. Currently, i m only able to load multiple fragments provided my layout has those number of fixed fragments.

推荐答案

绝对!查看Android开发人员指南中的片段.确保请参阅此处的第二个要点以及执行片段事务"部分: http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding

Absolutely! Check out the Android Developers guide to Fragments. Be sure the see the second bullet point here, as well as the "Performing Fragment Transactions" section: http://developer.android.com/guide/topics/fundamentals/fragments.html#Adding

此外,您可以在此类中查看用于管理片段的选项: http://developer.android.com/reference/android/app/FragmentTransaction.html

Additionally you can see your options for managing Fragments in this class: http://developer.android.com/reference/android/app/FragmentTransaction.html

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

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