Class must either be declared abstract or implement abstract method error

后端 未结 3 1791
一生所求
一生所求 2020-12-03 08:49

This is my code that is suppose to change some text on button press:-

public class MyActivity extends ActionBarActivity {
    TextView txtview;
    Button bu         


        
相关标签:
3条回答
  • 2020-12-03 09:10

    View.OnClickListener must implement the function onClick() otherwise your class should be abstract, so that you could implement your onClick() function in some child class. But in your case you have made a spelling mistake. It should be onClick() instead of Onclick();

    0 讨论(0)
  • 2020-12-03 09:15

    Tricks: add @Override above onClick(View). Without @Override, the warning means you didn't implement onClickListener.

    0 讨论(0)
  • 2020-12-03 09:20

    You got the method name wrong :

    public void Onclick(View paramView)
    

    should be

    public void onClick(View paramView)
    

    Following Java naming conventions can help you.

    0 讨论(0)
提交回复
热议问题