Reputation: 5
Whats wrong with my code? It doesn't work please help me! Error message as follows:
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new OnClickListener(){})" And another error message says "The method onClick(View) of type new OnClickListener(){} must override or implement a supertype method
my code is as follows:
ib.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Home.this, MainActivity.class);
startActivity(intent);
}
});
Upvotes: 0
Views: 1795
Reputation: 2310
ib.setOnClickListener(new OnClickListener() {
}
to
ib.setOnClickListener(new View.OnClickListener() {
}
and add the Activity in Manifest file
<Activity
android:name="package_name.Home">
</Activity>
Upvotes: 1