Chad
Chad

Reputation: 5

Not applicable arguments to method setOnClickListener

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

Answers (1)

Prakhar
Prakhar

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

Related Questions