【发布时间】:2017-02-11 16:12:33
【问题描述】:
Button button = (Button)findViewById(R.id.button1);
button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN ) {
//Insert desired code here
return true;
}
return false;
}
});
public void backtogreen(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
startActivity(intent);
}
如何修复此代码? 我有那个错误:
- 无法解析符号“setOnTouchListener” - 用于 setOnTouchListener
- 无效的方法声明;需要返回类型 - 用于 onTouchListener
- 此处不允许注释 - 用于公共布尔值之上的 @override
- 无法为两个“事件”解析符号“事件”
- 无法从结果类型为 void 的方法返回值以返回 true 并返回 false
请帮忙!
【问题讨论】:
标签: android android-activity ontouchlistener