admin管理员组

文章数量:1636998

关于使用内部类作为监听器出现的问题The type MainActivity.ButtonListener must implement the inherited abstract method D

我在debug时运行有错,显示:The type MainActivity.ButtonListener must implement the inherited abstract method DialogInterface.OnClickListener.onClick(DialogInterface, int)
此错误的解决办法是:方法一.将class ButtonListener implements OnClickListener{}改为android.view.View.OnClickListener方法二.将导入的包import android.content.DialogInterface.OnClickListener;给删了,导入import android.view.View.OnClickListener;包而导致这个问题的原因则是:我们最开始给写的OnClickListener导入包时导错了,应该导入的包是import android.view.View.OnClickListener;结果却导成了import android.content.DialogInterface.OnClickListener;这两个方法是不同的:一个是对话框对应按钮的点击监听器,另外一个是普通View的点击监听器。

本文标签: 部类监听器implementinheritedmethod