我是Android的新手,我想创建一个应用程序,所以,我看到很多教程,其中一些人说我需要使用片段,但在其他教程中说如果我想要或者只是当我的应用程序是对于平板电脑.所以,当我不得不使用片段时,我真的让我对此感到困惑.
请向我解释何时使用片段或何时不使用片段.谢谢
解决方法:
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
你提到的那些教程可能意味着:
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
当有一个大屏幕时,你不想留下空白空间.当屏幕太小时,你不想挤压一切.解决方案是使用2种不同的布局重用尽可能多的代码.那时片段特别方便.
总结以上是内存溢出为你收集整理的何时使用以及何时不在Android中使用片段?全部内容,希望文章能够帮你解决何时使用以及何时不在Android中使用片段?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)