-3

I am facing this problem and i want to find the reason that what is the need of passing this , to button & setOnClickListener .

1 Answers1

5

Context is interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

Button is also resource of application so if you want to create button or any widget then you have to pass Context in constructor of widget.

For more details

Rahul
  • 44,383
  • 11
  • 84
  • 103