What is the difference between Activity and View on Android?

Asked

Viewed 692 times

8

What’s the difference between Activity and View on Android?

1 answer

9


According to the documentation:

An Activity is a specific, singular action that a user can do. Almost all Activities interact with the user, so the Activity class takes care of creating the window for Voce in which Voce can integrate the user interface (UI) with setContentView(View).

In other words, Activity is like the base unit of a screen in an Android app.

Already the View:

This class represents the basic building block for components of the visual user interface. A view occupies a rectangular area on the screen and is responsible for "drawing" itself and handling events.

You should know Heritage, in Java the elements that you drag and drop to the screen like Textview, Edittext, Imageview, etc, inherit of this basic View class, which has a set of attributes and methods to control these components on the screen.

Using an analogy, the Activity is the structure of the house and the View are the furniture and everything that adds functionality to this structure.

I tried to translate the documentation and explain with my words, I hope it was clearer! Who has more information please comment or edit :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.