Android Eve
Android Eve

Reputation: 14974

The method call(Activity) in the type <type> is not applicable for the arguments (new View.OnClickListener(){})

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

Answers (3)

rogerkk
rogerkk

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

Hakan Ozbay
Hakan Ozbay

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

Dr. Benedict Porkins
Dr. Benedict Porkins

Reputation: 436

try this

IntentsUtils.call(UnderstandingIntents.this);

Upvotes: 1

Related Questions