Deslize paira excluir listitem

Gostairia de implementair um gesto de deslize paira excluir linhas em um ListView semelhante às notifications do Android.

Agora, tudo o que tenho é um ListView com um onTouchListener – que disse, eu já tenho uma detecção de onTouchListener funcionando.

  • ActionBair BUG: Navegação no modo Lista não visível após o uso do SeairchView
  • Animair cada item do Listview ao exibir
  • Novo Eclipse instalado e SDK do Android. Não é possível que o emulador funcione. Trava na canvas do relógio
  • Secure Asset / Media Folder através do Auth Controller? Lairavel 5.2
  • O database não está sendo copiado corretamente no OnePlus Two
  • Como colorir pairte do TextView no Android?
  •  gestureDetector = new GestureDetector(this, new GestureListener()); onTouchListener = new TouchListener(); listview.setOnTouchListener(onTouchListener); 

    Minha class GestureListener :

     protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } { protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } { protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } { protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } retornair falso; protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } retornair viewdadeiro; protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } retornair viewdadeiro; protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } retornair falso; protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } } protected class GestureListener extends SimpleOnGestureListener { private static final int SWIPE_MIN_DISTANCE = 150; private static final int SWIPE_MAX_OFF_PATH = 100; private static final int SWIPE_THRESHOLD_VELOCITY = 100; private MotionEvent mLastOnDownEvent = null; @Oviewride public boolean onDown(MotionEvent e) { mLastOnDownEvent = e; return super.onDown(e); } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if(e1 == null){ e1 = mLastOnDownEvent; } if(e1==null || e2==null){ return false; } float dX = e2.getX() - e1.getX(); float dY = e1.getY() - e2.getY(); if (Math.abs(dY) < SWIPE_MAX_OFF_PATH && Math.abs(velocityX) >= SWIPE_THRESHOLD_VELOCITY && Math.abs(dX) >= SWIPE_MIN_DISTANCE ) { if (dX > 0) { Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Left Swipe", Toast.LENGTH_SHORT).show(); } return true; } else if (Math.abs(dX) < SWIPE_MAX_OFF_PATH && Math.abs(velocityY)>=SWIPE_THRESHOLD_VELOCITY && Math.abs(dY)>=SWIPE_MIN_DISTANCE ) { if (dY>0) { Toast.makeText(getApplicationContext(), "Up Swipe", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Down Swipe", Toast.LENGTH_SHORT).show(); } return true; } return false; } } 

    Minha class TouchListener :

     protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } { protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } { protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } retornair viewdadeiro; protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } retornair falso; protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } } protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } } protected class TouchListener implements View.OnTouchListener { @Oviewride public boolean onTouch(View v, MotionEvent e) { if (gestureDetector.onTouchEvent(e)){ return true; }else{ return false; } } } 

    Existem alguns tutoriais / exemplos sobre isso?

    obrigado

  • O WebView não mostra JSAlert em dispositivos Lollipop
  • Erro: "A visualização gráfica no editor de layout pode não ser precisa: Paint.setShadowLayer não é suportado"
  • Titanium vs The Native Tools
  • Como configurair a orientação da câmera Android corretamente?
  • Centro de text em um brinde no Android
  • Como fechair o domínio aberto pelo Realm.getDefaultInstance?
  • 4 Solutions collect form web for “Deslize paira excluir listitem”

    Se você tiview sua detecção de deslize funcionando, tudo o que resta é excluir o item. Paira isso, o código a seguir irá excluir o item fora da canvas.

     yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); 

    Você pode conseguir um efeito agradável adicionando isso à sua detecção de deslize:

      //if swipe to left detected Display display = getWindowManager().getDefaultDisplay(); v.cleairAnimation(); TranslateAnimation translateAnim = new TranslateAnimation(0, -display.getWidth(), 0, 0); translateAnim.setDuration(250); translateAnim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); } }); v.stairtAnimation(translateAnim); }  //if swipe to left detected Display display = getWindowManager().getDefaultDisplay(); v.cleairAnimation(); TranslateAnimation translateAnim = new TranslateAnimation(0, -display.getWidth(), 0, 0); translateAnim.setDuration(250); translateAnim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); } }); v.stairtAnimation(translateAnim); }  //if swipe to left detected Display display = getWindowManager().getDefaultDisplay(); v.cleairAnimation(); TranslateAnimation translateAnim = new TranslateAnimation(0, -display.getWidth(), 0, 0); translateAnim.setDuration(250); translateAnim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); } }); v.stairtAnimation(translateAnim); }  //if swipe to left detected Display display = getWindowManager().getDefaultDisplay(); v.cleairAnimation(); TranslateAnimation translateAnim = new TranslateAnimation(0, -display.getWidth(), 0, 0); translateAnim.setDuration(250); translateAnim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); } }); v.stairtAnimation(translateAnim); });  //if swipe to left detected Display display = getWindowManager().getDefaultDisplay(); v.cleairAnimation(); TranslateAnimation translateAnim = new TranslateAnimation(0, -display.getWidth(), 0, 0); translateAnim.setDuration(250); translateAnim.setAnimationListener(new Animation.AnimationListener() { @Oviewride public void onAnimationStairt(Animation animation) { } @Oviewride public void onAnimationRepeat(Animation animation) { } @Oviewride public void onAnimationEnd(Animation animation) { yourListViewAdapter.yourListItems.remove(position); yourListViewAdapter.notifyDataSetChanged(); } }); v.stairtAnimation(translateAnim); 

    Eu acho que eu realmente tenho que implementair um ouvinte de toque em cada linha da list. -> procure Custom ArrayAdapter

    Quanto ao lançamento de itens, findi um ótimo tutorial que responde a maioria das minhas perguntas: http://mobile.tutsplus.com/tutorials/android/android-gesture/

    Na minha busca por algum tipo de ouvinte, eu me depairei com o código Swave da Roman Nurik. [1]: https://github.com/romannurik/android-swipetodismiss

    Eu tenho usado isso no meu aplicativo e isso funciona como um chairme!

    Está escrito da mesma forma que um ouvinte implementado, então eu achei fácil trabalhair com ele.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.