Reputation: 14974
Groping in the dark... This time I am receiving the following error in Eclipse:
The method call(Activity) in the type IntentsUtils is not applicable for the arguments (new View.OnClickListener(){})
This error refers to the call() line in a callback hooked up to a button, in a class that extends Activity:
public class UnderstandingIntents extends Activity {
...
...
...
// A call-back for when the user presses the testintents button.
OnClickListener mTestIntentsListener = new OnClickListener() {
public void onClick(View v) {
IntentsUtils.call(this);
}
};
}
IntentsUtils is a class copied verbatim from listing 3-33 here.
What does this error mean?
Upvotes: 0
Views: 679
Reputation: 5695
The this
parameter passed into IntentsUtils.call()
refers to the object within which it is being used, in this case an instance of OnClickListener
. Try replacing the this
parameter with UnderstandingIntents.this
:
IntentsUtils.call(UnderstandingIntents.this);
Upvotes: 2
Reputation: 4719
The problem here is that you are trying to reference the Activity Class (UnderstandingIntents) in an Anonymous inner class, hence when you say "this" it refers to View.OnClickListener(){}
to correct this do the following code:
IntentsUtils.call(UnderstandingIntents.this);
This way, your Activity class gets referenced.
Upvotes: 5
Reputation: 436
try this
IntentsUtils.call(UnderstandingIntents.this);
Upvotes: 1