Android的碎片和活动 [英] Android Fragments and Activities
问题描述
在谈到下图:
http://developer.android.com/guide/components/fragments.html
可能有人请,请解释为什么谷歌建议使用2个独立的活动,在手机和平板一个活动? 如果我有code的活性的管理片段B(对于平板电脑)我为什么要重复同样的code在b活动的电话?
Could someone please please explain why Google suggests to use 2 separate activities on a Phone and a single activity on a Tablet? If I have code in activity A to manage Fragment B (for a Tablet) why should I repeat the same code in Activity B for a phone?
看来,一个电话我仍然可以使用1活动,以及(唯一的活动A)和替换的片段,这样可以减少冗余code?
It seems that for a Phone I can still use 1 activity as well (only activity A) and replace fragments, this could reduce redundant code?
感谢。
推荐答案
我得到你的意思。
您可以使用一个片段容器和更换片段,定义界面选择回调。谷歌只是它这样也许它更清晰的为那些谁来自世界的活动我猜。
You could use a fragment container and replace the fragments, define interface for selection callback. Google just does it this way maybe its clearer for those who come from the activities world i guess.
这篇关于Android的碎片和活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!