Set background color of an element when touch - android
<p>Inside my <code>CustomAdapter</code> for a list, I want to change the background color of a row in my list when the user presses one of the rows.</p>

<p>I have a static class which contains the object in each row of the list:</p>

<pre><code>static class ViewHolder {
    ImageView image;
    TextView text;   
}
</code></pre>

<p>The holder contains the elements inside my list:</p>

<pre><code> holder = new ViewHolder();
 holder.image = (ImageView) convertView.findViewById(R.id.imageView1); 
 holder.text = (TextView) convertView.findViewById(R.id.textView1); 
 convertView.setTag(holder);

 holder.image.setImageResource(items.get(position).getImage());
 holder.text.setText(items.get(position).getTextToView());
</code></pre>

<p>To this convertView I added a <code>setOnTouchListener</code> this way:</p>

<pre><code> convertView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            switch(event.getAction()) {

            case MotionEvent.ACTION_DOWN:

                //Toast.makeText(c, "DOWN", Toast.LENGTH_SHORT).show();
                break;
            case MotionEvent.ACTION_UP:
                //Toast.makeText(c, "UP", Toast.LENGTH_SHORT).show();
                break;
            }

            return false;
        }

    });
</code></pre>

<p>I tried this:</p>

<pre><code>    convertView.setBackgroundColor(Color.RED); 
</code></pre>

<p>but my complier complaints, saying that the <code>convertView</code> should be <code>final</code> and that interfers with some other code.</p>

<p>This works perfectly to raise a <code>Toast</code> when the user presses a row in my list. 
But how can I change the background color of the row that is pressed? Thanks in advance. </p>
