Android的布局片段/活动混乱 [英] Android Layout Fragment/Activity Confusion
问题描述
我在做我的第一个Android应用程序与ActionBarSherlock。
I am making my first android application with the ActionBarSherlock.
应用程序将始终有一个操作栏由3个选项卡(默认选择第一个选项卡)。 该应用程序可扩展为与平板电脑使用。
The application will always have an action bar consisting of 3 tabs (first tab selected by default). The app could be extended for use with a tablet.
我一直在寻找的网页,并按照Android开发指南,但是我发现了一些东西混淆。 第一个选项卡的屏幕会随着项目的清单列表视图,onitemselected应该向用户发送到屏幕其特点有关该项目的更多细节。
I have been searching the web, and following the android development guides, however I am finding a few things confusing. The first tab screen will be a list view with a list of items, onitemselected should send the user to a screen which features more details about that item.
当我应该用一个片段?如果每个选项卡是一个片段? 或者,应该每个标签调用一个新的活动,其中包括片段? 而且,如果使用的片段,我应该将它们放置在不同的类别,或活动??
When should I use a fragment? Should each tab be a fragment? Or, should each tab call a new activity, which consists of fragments? And, if using fragments, should I place them in different classes, or embed them within an activity??
鸭preciate任何帮助,谢谢。
Appreciate any help, thanks.
推荐答案
我与碎片的经验主要是在ViewPager,所以我不能完全肯定它是否适用于这里。
My experience with Fragments is mostly on ViewPager, so I am not entirely sure if it applies here.
在Android的,你应该使用尽可能多的片段。根据经验,一般情况下,假设你要翻译的用户界面从手机到平板电脑,元素,可以住在一起,在相同的配置应该是一个片段。
In Android, you should use Fragments as much as possible. As a general rule of thumb, imagine you are translating the UI from phones to tablets, elements that can stay together in the same configuration should be a Fragment.
有一个片段子类,称为ListFragment,所以你可能要考虑为您的第一个标签。 (ListFragment是碎片像ListActivity是活动)
There is a Fragment subclass called ListFragment, so you might want to look into that for your first tab. (ListFragment is for Fragment like ListActivity is for Activity)
还有一个教程中,我发现处理片段。没有真正考虑它,但我希望它能帮助。
There is also a tutorial I found to deal with fragments. Did not really look into it but I hope it helps.
HTTP://android.$c$candmagic .ORG / 2011/07 / Android的标签 - 与片段/
至于动作条/ ActionBarSherlock,我绝对没有经验withit所以有人可能要补充。
As for ActionBar / ActionBarSherlock, I have absolutely no experience withit so someone might want to add to that.
这篇关于Android的布局片段/活动混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!