当使用时不要在Android中使用的片段? [英] When to use and when not to use fragments in Android?
问题描述
我在Android的新的和我想打一个应用程序,所以,我看到了很多的教程和一些人说,我需要使用的片段,但在其他的教程说,如果我想,或者只在我的应用是平板电脑。所以,我真的让我混淆这个,当我不得不使用片段时,我没有。
请,给我解释一下什么时候使用碎片或不用时。谢谢
一个片段是可由一个一起使用的独立分量
活动。片段封装功能,以便更容易
活动和布局中重用。
块引用>http://www.vogella.com/articles/AndroidFragments/article。 HTML片段#
的但在其他的教程说,如果我想,或者只在我的应用是平板电脑的
块引用>您提到的那些教程大概意思是:
片段可以很容易地重新使用不同的布局组件,例如
你可以建立手机(电话)单面板的布局和多窗格
布局片。这并不限于片;比如你
可以使用碎片还能够支持不同的布局和景观
在智能手机上纵向。
块引用>http://www.vogella.com/articles/AndroidFragments/article。 HTML#fragments_usage
当有你不想留出空白空间大幕。当屏幕太小,你不想挤一切。解决的办法是有2个不同的布局重用尽可能多code越好。这是当
片段
是特别方便。I am new in Android and I want to make an app, so, I was seeing a lot of tutorials and a few of them said that I need to use fragment, but in others tutorials say that if I want or only when my app is for Tablets. So, I really get me confuse about this, when I have to use fragment and when I not.
Please, explain to me when to use fragments or when not. thanks
解决方案A fragment is an independent component which can be used by an activity. A fragment encapsulate functionality so that it is easier to reuse within activities and layouts.
http://www.vogella.com/articles/AndroidFragments/article.html#fragments
but in others tutorials say that if I want or only when my app is for Tablets
Those tutorials you mentioned probably meant this:
Fragments make it easy to reuse components in different layouts, e.g. you can build single-pane layouts for handsets (phones) and multi-pane layouts for tablets. This is not limited to tablets; for example you can use fragments also to support different layout for landscape and portrait orientation on a smartphone.
http://www.vogella.com/articles/AndroidFragments/article.html#fragments_usage
When there is a big screen you don't want to leave empty space. When the screen is too small you don't want squeeze everything. The solution is to have 2 different layouts reusing as much code as possible. That is when
Fragments
are especially handy.这篇关于当使用时不要在Android中使用的片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!