What is the difference between Activity and View on Android?

8

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

    
asked by anonymous 17.02.2017 / 02:53

1 answer

8

According to documentation :

  

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

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

Already at View :

  

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

You should know Inheritance, in Java the elements you drag and drop to the screen like TextView, EditText, ImageView, etc., inherit from that View base class, which has a set of attributes and methods to control these components on the screen.

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

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

    
17.02.2017 / 03:12