Android设计:片段或看法? [英] android design : fragment or view?

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

问题描述

当设计一个Android应用程序,这个问题经常弹出:
它是更好地设计一个给定的UI组件作为视图或片段?

其中标准可用于选择2?
在这种情况下,在这种情况下你preFER一个到另一个?

注1:
我知道这个问题的格式可能没有适合这个堆栈的网站,但我认为这个问题是相关的社区。

注2:
带着这个疑问,我不是真的找一个明确的答案(虽然我可能是错的),但我在寻找一个集体反思,经验分享关于该事项。


解决方案

要回答你,摆脱一些意见挑剔的:

*视图是屏幕元素。把它们当作窗口。在MVC模式,他们是在V。

*片段是在一个MVC模式的控制器。他们通常拥有一堆意见,用于定义用户如何与程序的意见进行交互。

*活动是在一个MVC模式的控制器。它们可含有的观点或片段的任何数量(包括0)。片段用于活动分解为独立的部分,如果有容易分离功能一个足够大的子集。

When designing an Android app, the question often pops up : Is it better to design a given UI component as a view or as a fragment ?

Which criteria can be used to choose the 2 ? In which situation, in which case do you prefer one to the other ?

Note 1: I know the format of this question may not been suitable for this stack site but I think the question is relevant for the community.

Note 2: With this question, I am not really looking for a definitive answer (though I could be wrong), but I am looking for a collective reflection, experience sharing on that matter.

解决方案

To answer you and get out of some of the nitpicking in comments:

*Views are onscreen elements. Think of them as windows. In a MVC pattern, they're the V.

*Fragments are controllers in a MVC pattern. They typically own a bunch of views, and are used to define how the user interacts with those views in the program.

*Activities are controllers in a MVC pattern. They can contain any number (including 0) of views or fragments. Fragments are used to break up an activity into separate pieces if there's a big enough subset of easily separated functionality.

这篇关于Android设计:片段或看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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