Darius
Darius

Reputation: 5259

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

Upvotes: 4

Views: 1301

Answers (1)

John Feminella
John Feminella

Reputation: 311496

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.

Upvotes: 6

Related Questions