当有 onclick, ontouch 监听器附加到 sameImageView
时,触摸优先于点击。
我想要ImageView
对 2 个不同的动作做出反应:滑动和单击。我该怎么做呢?现在,我这样做:
swipe_area.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x1 = event.getRawX();
break;
case MotionEvent.ACTION_UP:
x2 = event.getRawX();
if (x1 < x2) {
switch (pencil_counter) {
case 1:
zad.setBackgroundResource(R.drawable.page13_zad6);
pered.setBackgroundResource(R.drawable.page13_pered6);
pencil_counter = 6;
break;
case 2:
zad.setBackgroundResource(R.drawable.page13_zad1);
pered.setBackgroundResource(R.drawable.page13_pered1);
pencil_counter = 1;
break;