What does Class.this mean?

Vamsi Rao

I do understand that Class.this used in case of nested classes but I came across a code which is using it without any nested classes.

// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);

// Set a click listener on that View
numbers.setOnClickListener(new View.OnClickListener() {
   // The code in this method will be executed when the numbers View is clicked on.
   @Override
   public void onClick(View view) {
       Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);
       startActivity(numbersIntent);
   }
});

In the line:

 Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);

Why is MainActivity.this used and why can't we use this.

Pushpendra

Because here new View.OnClickListener() is anonymous inner class.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What does :: mean in class signature?

From Dev

What does this class declaration mean?

From Dev

What does it mean to destroy a class

From Dev

What does it mean by Lock on class?

From Dev

What does this class declaration mean?

From Dev

What does "unload class" mean?

From Dev

What does "Class<?" mean in Java?

From Dev

What does :: mean in class signature?

From Dev

What does it mean for a class to be composed of another class?

From Dev

What does the keyword `constructor` mean in the class title?

From Dev

What does inherited mean in the context of class operators

From Dev

what does exclude in the meta class of django mean?

From Dev

What does a # in a comment between class and method mean?

From Dev

What does this syntax mean in the declaration of an abstract class?

From Dev

What does `class =` inside template mean?

From Dev

What does [+A] mean in Scala class declaration?

From Dev

CSS - What does asterisk before class mean?

From Dev

What does it mean for void to be a "first class type"?

From Dev

What does "Illegal Class Literal" mean?

From Dev

What does (new Class())->Function(); mean?

From Dev

What does it mean to decorate a class or parameter?

From Dev

What does this c++ class declaration mean?

From Dev

What does it mean to "place" a type in a class?

From Dev

What does "class loading deadlock" mean here?

From Dev

What does @class mean in objc files

From Dev

What does the keyword `constructor` mean in the class title?

From Dev

CSS - What does asterisk before class mean?

From Dev

What does <T?> mean in Class declaration?

From Dev

What does "invalid file flags in class" mean?

Related Related

HotTag

Archive