Context vs views

can someone explain the difference between context and representations , and when will we search for context or representation? In most programs, I find that a context or view is passed to certain methods, what is the actual need to pass a context or view methods?

+7
source share
1 answer

This is a strange question. View describes one element of your ui. It can have onClickListeners, properties, and so on. But each view is created in a certain context, usually in the context of an action.

The context itself is a bit of an environment in which your code runs. It has access to ui (if it is activity), it can contain some global data (application context) and has access to resources (all contexts). In addition, the context allows you to perform ordinary Android operations, such as broadcasting, launching actions and services.

So, views should be passed when you want to do something with a specific view. The context is passed when you need access to resources, global data or the ui context, or the launch of other Android components.

+15
source

All Articles