[英]Android different Ontouchlistener's is not working at the same time
This will be a remoting Touchpad application . 这将是一个远程的Touchpad应用程序。 I implemented 3 ontouchlisteners and they are touchpad , leftclick and rightclick but these listeners are not working at the same time .
我实现了3个ontouchlisteners,它们分别是touchpad,leftclick和rightclick,但是这些侦听器不能同时工作。 For example when I try to do remote touchpad leftclick or right click button is not working .
例如,当我尝试做远程触摸板时,leftclick或right click按钮不起作用。 Or when I click to the leftbutton the others are not working .
或者,当我单击向左按钮时,其他按钮则无法工作。 Here are the codes I couldn't find the answer how to solve this issue .
这是我找不到解决该问题的答案的代码。
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);
}
});
Use individual FrameLayout object for each FrameLayout. 为每个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);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.