What can I do when I get the error "it is impossible to solve the problem"?

I am trying to create a button on mainActivity. After clicking on it, the user switches to the second view. However, I continue to be mistaken in saying that

onclick listener cannot be allowed for type

and

the set onclicklistener method in the type view is not applicable for the type of arguments

Below is a screenshot of the code:

Does anyone have any ideas?

+3
source share
5 answers

This is because the source file still does not have the required imports for the classes you want to use.

You can always automatically add missing imports using Eclipse:

Ctrl+ Shift+O

, , .

+10

, , , , xml... :

public void onClick(View v) {
    startActivity(new Intent(Second.this, Third.class));
}

, "third.class"

public void onClick(View v) {
    startActivity(new Intent(Second.this, Third.class));
}
+3

import android.view.View.OnClickListener;

import it

+2
source

From the Android API :

button.setOnClickListener(new View.OnClickListener()
+1
source

Use

this.insertionButton.setOnClickListener(new View.OnClickListener){});

and yes also import the above classes or press ctrl + shift + o

+1
source

All Articles