btnAdd.setOnTouchListener(new OnTouchListener() {
private boolean isRun = true;
private long keyDownMills = -1;
@Override
public boolean onTouch(View v, MotionEvent event) {
Logcat.d("btn", event.toString());
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
keyDownMills = System.currentTimeMillis();
new Thread() {
@Override
public void run() {
super.run();
isRun = true;
try {
sleep(250);
while (isRun) {
addBtn();
handler.sendEmptyMessage(HANDLER_DATA_FRESH);
sleep(250);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}.start();
break;
case MotionEvent.ACTION_UP:
isRun = false;
if (System.currentTimeMillis() - keyDownMills < 250)
performClick();
break;
}
return false;
}
});
android-code-btn实现长按连击效果
最新推荐文章于 2022-06-15 15:34:55 发布