我有一个自定义视图,我将其添加到相对布局中,并且仅将触摸侦听器添加到自定义视图中。问题是未调用 onTouchevent。请帮助我的实际代码中的示例代码::
ViewGroup base = (ViewGroup)findViewById(R.id.base); //relative layout
base.addView(move);
move.setOnTouchListener(touchListener);
OnTouchListener touchListener = new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.d("onTouch v","="+v);
if(v instanceof MovingView) {
return false;
}
else
return true;
}
public boolean onTouchEvent(MotionEvent event) {
int x = (int)event.getX();
int y = (int)event.getY();
}
};// close listener