这将是远程Touchpad应用程序。我实现了3个ontouchlisteners,它们是触摸板,leftclick和rightclick,但这些听众不能同时工作。例如,当我尝试做远程触摸板leftclick或右键单击按钮不起作用。或者,当我点击左按钮时,其他按钮不起作用。以下是我无法找到解决此问题的答案的代码。
fl = (FrameLayout) findViewById(R.id.TouchPad);
fl.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return Mouse(ev);
}
});
fl = (FrameLayout) this.findViewById(R.id.LeftButton);
fl.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return LeftClick(ev);
}
});
fl = (FrameLayout) this.findViewById(R.id.RightButton);
fl.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return RightClick(ev);
}
});
答案 0 :(得分:0)
为每个FrameLayout使用单独的FrameLayout对象。
fl = (FrameLayout) findViewById(R.id.TouchPad);
fl.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return Mouse(ev);
}
});
f2 = (FrameLayout) this.findViewById(R.id.LeftButton);
f2.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return LeftClick(ev);
}
});
f3 = (FrameLayout) this.findViewById(R.id.RightButton);
f3.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent ev) {
return RightClick(ev);
}
});