开发者

How are activities and views related in the Android platform?

I am attempting to learn how to develop on the Android platform but do not quite understand the relationship between Activities and Views, because according to the documentation an Activity is almost always linked to a UI object that the user can interact with, but if this is the case where does the whole idea of Views come in?

There is probably a开发者_开发问答 very basic explanation but I would appreciate a few pointers all the same. Thanks


An activity is a user interface for carrying out some task, and is closer to what you might think of as a Form or Window in other frameworks. A View is a self-controlled rectangular section of a window that interaction can occur in, and is a much lower-level representation of UI. It's closer to what you might think of when you hear Control or Widget in a different framework.

The visual content of a window is provided by a hierarchy of views, which are objects derived from the base View class. Each and every view controls a rectangular space within the window. A parent view contains and organizes the layout of its children; leaf views, at the bottom of the hierarchy, actually draw in the rectangles they control and respond to user actions. Thus, a view is where an activity's interaction with the user actually takes place.

You'll probably want to read Android Fundamentals; it's a good starting point in the Android documentation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜