Android 如何仅对一个按钮使用此代码?
如何仅对一个按钮使用此代码? 我不能改变这个 公共布尔onTouchEvent(运动事件) { boolean[]newButtonStates=新布尔值[24]Android 如何仅对一个按钮使用此代码?,android,sample,Android,Sample,如何仅对一个按钮使用此代码? 我不能改变这个 公共布尔onTouchEvent(运动事件) { boolean[]newButtonStates=新布尔值[24] int action=event.getAction(); 布尔值isDownAction=(action&0x36)=0x36 | | action==MotionEvent.action|U DOWN | | action==MotionEvent.action|U MOVE; 对于(int-touchIndex=0;touch
int action=event.getAction();
布尔值isDownAction=(action&0x36)=0x36 | | action==MotionEvent.action|U DOWN | | action==MotionEvent.action|U MOVE;
对于(int-touchIndex=0;touchIndex
我想你需要做的是:
Button myBtn = (Button) findViewById(R.id.btn);
myBtn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){
// Do what you want
return true;
}
return false;
}
});
你到底想用这段代码做什么?一点解释会很有帮助。实现按钮的onTouchListener。如果我从屏幕的其他位置用手指拖动按钮来触摸按钮,会发生什么事件?请给我一个sampleno我不想要这个。当从屏幕的另一个状态拖动手指到按钮上时,这段代码不起作用。
Button myBtn = (Button) findViewById(R.id.btn);
myBtn.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_UP){
// Do what you want
return true;
}
return false;
}
});