noMAD
noMAD

Reputation: 7844

compiler complains on onClickListener()

I am just starting on android programming. While trying out something the compiler is complaining on this:

Button button1main = (Button) findViewById(R.id.Button01mainOk);
button1main.setOnClickListener(new onClickListener() {
    public void onClick(View v)
    {
        //Blah
    });

The compiler complains The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new onClickListener(){}) but I checked Google for examples and I found a couple of them using the same as above.

Upvotes: 0

Views: 68

Answers (1)

Jani Bela
Jani Bela

Reputation: 1670

Try,

Button button1main = (Button) findViewById(R.id.Button01mainOk); 
button1main.setOnClickListener(new View.onClickListener() { 
    public void onClick(View v) 
    { 
        //Blah 
    }); 

I always do like this, but not 100% that the problem is this.

Upvotes: 2

Related Questions