wagashi
wagashi

Reputation: 894

Android & Java simple Code

I Wonder what is and does (this) in this code:

Button btn = new Button(this); 

Upvotes: 0

Views: 279

Answers (2)

MByD
MByD

Reputation: 137272

this refers to the current object, which is probably the Activity. Activity extends Context, and it is passed as Context to the Button constructor.

Upvotes: 5

Dmytro Danylyk
Dmytro Danylyk

Reputation: 19788

Its a reference to the Context

Upvotes: 4

Related Questions