方法不会覆盖android中超类java @override的方法

时间:2016-09-04 02:21:22

标签: android onclicklistener

我正在尝试制作计算器应用程序,但是我因为重写OnClickListner

而收到错误

BtnAdd.setOnClickListener(new View.OnClickListner(){

           @Override // getting red line here asking method does not override super class 
            public void onClick(View v){
               Toast.makeText(getActivity(), "this is my Toast message!!! =)",
                       Toast.LENGTH_LONG).show();
           }
        });

1 个答案:

答案 0 :(得分:0)

它不是getActivity getApplicationContext

@Override // getting red line here asking method does not override super class 
public void onClick(View v) {
     Toast.makeText(getApplicationContext(), "this is my Toast message!!! =)",
         Toast.LENGTH_LONG).show();
     }
});