Eclipse写android监听事件老报错
bn1.setOnClickListener(newButton.OnClickListener(){@OverridepublicvoidOnClick(Viewv){...
bn1.setOnClickListener(new Button.OnClickListener()
{
@Override
public void OnClick(View v){…… }
});
如上代码,会在“Button.OnClickListener()”报错:The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View)
还有“OnClick(View v)”报错:The method OnClick(View) of type new View.OnClickListener(){} must override or implement a supertype method
用eclipse的纠错建议,自动补完的重载OnClick(View v){…… }就没问题。这算咋回事?不让手敲代码?! 展开
{
@Override
public void OnClick(View v){…… }
});
如上代码,会在“Button.OnClickListener()”报错:The type new View.OnClickListener(){} must implement the inherited abstract method View.OnClickListener.onClick(View)
还有“OnClick(View v)”报错:The method OnClick(View) of type new View.OnClickListener(){} must override or implement a supertype method
用eclipse的纠错建议,自动补完的重载OnClick(View v){…… }就没问题。这算咋回事?不让手敲代码?! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询