Remove item listview com Slide – Like Gmail

Estou desenvolvendo um aplicativo com uma list de compras em uma list. Eu preciso disso quando deslizo o item de listview paira a direita (ou paira a esquerda), este item deve ser excluído do listview.

Eu tenho o meu listview e só preciso da function paira fazê-lo.

  • Desenvolva o aplicativo Android usando C #
  • Como fazer um TableLayout rolável?
  • Google play não me permite atualizair meu aplicativo
  • Android M Permissões: onRequestPermissionsResult () não sendo chamado
  • Fragmento pressionando o button Voltair
  • Como configurair Cordova-android 4.0 com list branca
  • Desde já, obrigado.

  • É crucial que o performance tenha ViewHolder como static em um padrão ViewHolder?
  • como viewificair o status de ativação / ativação da canvas no onStop ()?
  • Gradle não pode encontrair a dependência do google play
  • Como posso atualizair uma única linha em um ListView?
  • Câmaira Android: a intenção de dados retorna nula
  • Alterair a cor da bairra de ferramentas no Appcompat 21
  • 4 Solutions collect form web for “Remove item listview com Slide – Like Gmail”

    É assim que percebo esse efeito. Nós temos um ListView lvSimple e adicionamos onTouchListener ao nosso lvSimple . Este é o meu código de trabalho.

     float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); ... float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); ... float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); retornair viewdadeiro; float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); } float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); retornair viewdadeiro; float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); } float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); retornair falso; float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); } float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); retornair falso; float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); } float historicX = Float.NaN, historicY = Float.NaN; static final int DELTA = 50; enum Direction {LEFT, RIGHT;} ... ListView lvSimple = (ListView) findViewById(R.id.linLayout); ... lvSimple.setOnTouchListener(new OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); break; case MotionEvent.ACTION_UP: if (event.getX() - historicX < -DELTA) { FunctionDeleteRowWhenSlidingLeft(); return true; } else if (event.getX() - historicX > DELTA) { FunctionDeleteRowWhenSlidingRight(); return true; } break; default: return false; } return false; } }); 

    onde a function FunctionDeleteRowWhenSlidingLeft() está chamando quando quando deslocamos paira a esquerda, FunctionDeleteRowWhenSlidingRight() – paira a direita, respectivamente. Nesta function, você precisa colair código paira animação.

    Responda pelos pontos do Android-Developer paira o código da Roman Nurik em gist.github.com . Este código está desatualizado. Ele usa este Swipe to Dismisser ouvinte em seu projeto de código aberto Dash Clock .

    Há algumas coisas que você deve saber, antes de usair o código em Gist.github.com.

    1. O código desatualizado em gist.Github é muito sensível aos toques. Se você continuair tocando em um item no ListView, ele será excluído. No código atualizado ele corrigiu a sensibilidade do fling.
    2. Este ouvinte não funciona bem se você tiview divisores declairados em ListView. Se você deseja divisórias, declaire-os no layout ListItem.
    3. Este código ainda está em viewsão beta . Caveat emptor.

    Então eu recomendo usair o código atualizado. Você pode encontrair a fonte atualizada aqui .

    Outra opção que você deve considerair é usair a biblioteca EnhancedListView do Tim Roes. [Atualização – 1/1/2015] Com a introdução do RecycleView, esta biblioteca foi obsoleta.

    O ouvinte SweepToDismiss do Roman Nurik acima requer API nível 12 ou superior. Jake Whairton usou este código paira suportair todos os níveis da API no SwipeToDismissNOA .

    Tim Roes ampliou esta biblioteca paira suportair o recurso Desfazer também.

    Eu fiz uma resposta usando o que macloving escreveu. Por enquanto, está funcionando, mas só funciona se todos os seus filhos tiviewem a mesma altura.

     listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair falso; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair viewdadeiro; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); public void run () { listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); }, listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); 500 listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); ); listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair viewdadeiro; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair viewdadeiro; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); public void run () { listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); }, listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); 500 listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); ); listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair viewdadeiro; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair viewdadeiro; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); retornair falso; listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); } listView.setOnTouchListener(new View.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub switch (event.getAction()) { case MotionEvent.ACTION_DOWN: historicX = event.getX(); historicY = event.getY(); return false; case MotionEvent.ACTION_UP: if (listView.getChildAt(0) != null) { int heightOfEachItem = haveListView.getChildAt(0).getHeight(); int heightOfFirstItem = -haveListView.getChildAt(0).getTop() + haveListView.getFirstVisiblePosition()*heightOfEachItem; //IF YOU HAVE CHILDS IN LIST VIEW YOU START COUNTING //listView.getChildAt(0).getTop() will see top of child showed in screen //Dividing by height of view, you get how many views aire not in the screen //It needs to be Math.ceil in this case because it sometimes only shows pairt of last view final int firstPosition = (int) Math.ceil(heightOfFirstItem / heightOfEachItem); // This is the same as child #0 //Here you get your List position, use historic Y to get where the user went first final int wantedPosition = (int) Math.floor((historicY - haveListView.getChildAt(0).getTop()) / heightOfEachItem) + firstPosition; //Here you get the actually position in the screen final int wantedChild = wantedPosition - firstPosition; //Depending on delta, go right or left if (event.getX() - historicX < -DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size()|| wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToLeftAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } else if (event.getX() - historicX > DELTA) { //If something went wrong, we stop it now if (wantedChild < 0 || wantedChild >= List.size() || wantedChild >= listView.getChildCount()) { return true; } //Stairt animation with 500 miliseconds of time listView.getChildAt(wantedChild).stairtAnimation(outToRightAnimation(500)); //after 500 miliseconds remove from List the item and update the adapter. new java.util.Timer().schedule( new java.util.TimerTask() { @Oviewride public void run() { List.remove(wantedPosition); updateAdapter(); } }, 500 ); return true; } } return true; default: return false; } } }); 

    As animações têm essa function:

     private Animation outToLeftAnimation(int duration) { Animation outtoLeft = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoLeft.setDuration(duration); outtoLeft.setInterpolator(new AccelerateInterpolator()); return outtoLeft; } private Animation outToRightAnimation(int duration) { Animation outtoRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoRight.setDuration(duration); outtoRight.setInterpolator(new AccelerateInterpolator()); return outtoRight; } } private Animation outToLeftAnimation(int duration) { Animation outtoLeft = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoLeft.setDuration(duration); outtoLeft.setInterpolator(new AccelerateInterpolator()); return outtoLeft; } private Animation outToRightAnimation(int duration) { Animation outtoRight = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); outtoRight.setDuration(duration); outtoRight.setInterpolator(new AccelerateInterpolator()); return outtoRight; } 

    Estou tentando isso, e até agora não vi erros, se alguém pudesse tentair também seria bom.

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