Inherited method seems to be disowned by its ancestor

I'm still getting, "The type OnDemandAndAutomatic_Activity must implement the inherited abstract method View.OnClickListener.onClick(View)"

even though I've implemented the method in two places (placed in both places via "Quick Fix").

This is my code:

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class OnDemandAndAutomatic_Activity extends Activity implements View.OnClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ondemandandautomatic_activity);

        // try commenting the button code out to see if that lets it run...
        Button buttonAuthorizeUsers = (Button) findViewById(R.id.buttonAuthorizeUsers);
        buttonAuthorizeUsers.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent configure = new  Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class);  
                OnDemandAndAutomatic_Activity.this.startActivity(configure);
            }});
    }

/*  @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Intent configure = new  Intent(OnDemandAndAutomatic_Activity.this, Configure_Activity.class);  
        OnDemandAndAutomatic_Activity.this.startActivity(configure);
    }*/

}

Upvotes: 0

Views: 676

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Since OnDemandAndAutomatic_Activity claims to implement View.OnClickListener, you need to have the onClick() implementation that you have commented out, otherwise it will not compile.

Also, you are separately presently creating an anonymous inner class instance of View.OnClickListener that you are passing to setOnClickListener(). It too will need an implementation of onClick().

If you are thinking that you should only need one of these, then either remove implements View.OnClickListener from your class declaration or pass this to setOnClickListener().

Upvotes: 2

Related Questions