title: onTouch method with ViewHolder Android
body: <p>I have a BaseAdapter that implements OnTouchListener class. The onTouch method is:</p>
  
  <pre><code>@Override
  public boolean onTouch(View v, MotionEvent event) {
  
      switch (event.getAction()) {
  
      case MotionEvent.ACTION_DOWN: {
          startY = event.getY();
          break;
      }
  
      case MotionEvent.ACTION_UP: {
          float endY = event.getY();
  
          if (endY &gt; startY) {
              layoutComments.startAnimation(animDown);
              layoutComments.setVisibility(View.GONE);
          }
  
      }
  
      }
      return true;
  }
  </code></pre>
  
  <p>The problem in that the layoutComments variable is inserted in a ViewHolder declarated in a getView method:</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
      final ViewHolder holder;
  ...
  ...
  </code></pre>
  
  <p>The program can't view the variable, and there are two compiler errors. How can I get the ViewHolder from the variable v of the onTouch?</p>