Max Koretskyi
Max Koretskyi

Reputation: 105517

Implementing View.OnClickListener for the activity - method is not overriden

Here is my activity code:

public class TextsListActivity extends ActionBarActivity implements View.OnClickListener {

    @Override
    public void OnClick(View button) {

    }
}

Android Studio warns that Method does not override method from its superclass and also another warning that TextsListActivity should implement onClick. What have I done wrong?

Upvotes: 1

Views: 124

Answers (1)

Juan Cortés
Juan Cortés

Reputation: 21112

The declaration of the method has a lowercase letter "o", you're really not overriding the one you think you are. Keep in mind that the view may or may not be a Button, any View can potentially receive a click event.

 public void onClick(View v) {} //as opposed to OnClick


Tip: The next time, if you press alt while having the cursor on an error you will be prompted with some possible solutions to the situation. In this case, it would've suggested to implement onClick(View v)

Upvotes: 2

Related Questions