报错一:The type new DialogInterface.OnClickListener(){} must implement the inherited abstract method DialogInterface.OnClickListener.onClick(DialogInterface, int)
或
报错二:The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View)
或
报错三:The method onClick(DialogInterface, int) of type new View.OnClickListener(){} must override or implement a supertype method
报这个错的根本原因是,在同一个activity中需要用到普通单击监听和弹出框单击监听,而这两种单击事件监听需要引用不同的包。
即
import android.view.View.OnClickListener;
import android.content.DialogInterface.OnClickListener;
而同时添加两种引用又会冲突。
解决办法是,只添加一种引用,代码用到另一种单击事件监听时添加完整路径即可。
例如:
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(PersonList.this, "Home键被点击", Toast.LENGTH_SHORT).show();
}
});