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
mainActivity
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?
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
, , .
, , , , xml... :
public void onClick(View v) { startActivity(new Intent(Second.this, Third.class)); }
, "third.class"
import android.view.View.OnClickListener;
import it
From the Android API :
button.setOnClickListener(new View.OnClickListener()
Use
this.insertionButton.setOnClickListener(new View.OnClickListener){});
and yes also import the above classes or press ctrl + shift + o