title: Android ListView - getting a number of element in the list in ListView.setOnTouchListener
body: <p>I'm trying to get the list item number in the onTouch method. That is how i do it:</p>
  
  <pre><code>ListView myList;
  
  
  
  ...
  myList.setOnTouchListener(new OnTouchListener() {
  
                  @Override
                  public boolean onTouch(View v, MotionEvent event) {
                      doSomething(myList, event);
                      return false;
                  }
              });
  
  ...
  private void doSomething(ListView myList, MotionEvent event) {
  
      if (event.getAction() == MotionEvent.ACTION_DOWN) {                                         
          int first = myList.getFirstVisiblePosition();
          int last = myList.getLastVisiblePosition();
          int itemHeight = myList.getHeight() / (last - first + 1) + myList.getDividerHeight();
          int position = (int)event.getY() / itemHeight;
          View child = myList.getChildAt(position);
  
  ...
  </code></pre>
  
  <p>It seems to be not correct, because sometimes I get wrong position. How can i fix it?</p>