Reputation: 1447
I am new to android and following the official Android guide.
Sometimes I can't understand some keywords in the example codes,
like it
, this
, and activity
.
Suppose I have to call a dialog like this:
SampleDialog().show([email protected], null)
What does this@Activity
mean?
Upvotes: 3
Views: 1644
Reputation: 541
this
is like a this
keyword from Java which is a reference to the current object. So, this@MainActivity
in Kotlin is equivalent to MainActivity.this
in Java. Can read more at this and this.
it is an implicit name of a single parameter in lambda function.
activity
is like getActivity()
when calling from a fragment. It returns the FragmentActivity this calling fragment is currently associated with.
Upvotes: 3