简体   繁体   中英

Pass this object into event handler

I got the code below how do I pass the current object "this" into the event handler so that I can pass it to the object Foo:

btn.setOnClickListener(new View.OnClickListener(this) {
public void onClick(View view) {
   new Foo(this).AlertBox("Hello Lennie!");
}
});

Where "this" is: android.app.Activity

i get an error that it can't find the constructor:

new Foo(android.app.Activity.this).AlertBox(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM