Error due to invalid combination of Toast and OnClickListener

前端 未结 7 2138
醉梦人生
醉梦人生 2021-01-31 08:54

I\'m trying to use Toast inside OnCLickListener. My code triggers the following error:

The method makeText(Context, CharSequence, int)          


        
7条回答
  •  感动是毒
    2021-01-31 09:03

    In this case, this refers to the instance of the anonymous subclass of View.OnClickListener. You have to refer to the this of the class where you create the anonymous class.

提交回复
热议问题