【发布时间】:2017-02-26 10:51:32
【问题描述】:
为什么当我为 onLongClickListener 创建一个 void 方法时,在 android studio 中会出现这个错误? 错误 =>
'onLongClick(View)' in 'Anonymous class derived from android.view.View.OnLongClickListener' clashes with 'onLongClick(View)' in 'android.view.View.OnLongClickListener'; attempting to use incompatible return type
我的代码是:
myBTN.setOnLongClickListener(
new Button.OnLongClickListener(){
public void onLongClick(View v){
TextView lblm=(TextView) findViewById(R.id.txtMessage);
lblm.setText("Good Bye :| ");
}
}
);
但是当我使用布尔方法时,没有错误
myBTN.setOnLongClickListener(
new Button.OnLongClickListener(){
public boolean onLongClick(View v){
TextView lblm=(TextView) findViewById(R.id.txtMessage);
lblm.setText("Good Bye :| ");
return true;
}
}
);
【问题讨论】:
标签: java android boolean void onlongclicklistener