Android this and activity The difference between this

There are two situations when writing statements:

Search Google in English for what's difference between this and activity This finally has a result (in fact, I used classname.this and this in Java, and the previous search was activity.this, so there was no result. I should flexibly improve my search ability).

The answer is found in stackoverflow:

http://stackoverflow.com/questions/10102151/whats-the-difference-between-this-and-activity-this

this refers to your current object. In your case you must have implemented the intent in an inner class ClickEvent,and thats what it points to. Activity. this points to the instance of the Activity you are currently in.

This is the reference of your current object. In your example, you must implement intent in the internal class clickevent. It points to clickevent, not the activity you want to pass in.

Activity. This refers to an instance and reference of the activity name you filled in.

In fact, this is the basis of Java. I forgot it myself.

As the current object, it is OK to use this directly in the activity. When this is used in the anonymous inner class, the current object will become the inner class of new, and if the thing you pass in is the whole activity, it needs activity This.

Therefore, you need to specify which activity it is. Move the toast statement outside and delete the alarmactivity.

So it's still suggested by netizens to use it all as activity This, clear.

The above is Android this and activity This is the difference between the data sorting, follow-up to continue to supplement relevant information, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>