Pourquoi mettre setBackgroundColor ne fonctionne pas dans mon habitude listView

J'ai un custom listView. La principale mise en page xml est quelque chose comme ceci:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <ListView android:layout_height="wrap_content" 
              android:id="@+id/lv_clientes"
              android:layout_width="0dp">
    </ListView>
<!-- From this part there are not problems -->
</LinearLayout>

La liste de l'élément XML est ce

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/rlo_elemento"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
    <TextView android:id="@+id/tv_nombre"
              android:layout_width="wrap_content" 
              android:layout_height="wrap_content">
    </TextView>
    <!-- From this part there are not problems -->
</RelativeLayout>

Maintenant la carte est comme ceci:

public class AdapterListaClientes extends BaseAdapter
{
    private Cliente[] data;
    Context context;
    LayoutInflater layoutInflater;
    int itemSelected = -1;

    public void setSelected(int valor)
    {
        itemSelected = valor;
    }

    public AdapterListaClientes(Context context, ArrayList<Cliente> data)
    {
        this.data = data.toArray(new Cliente[0]);
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
    }
/*Mandatory things and so...*/

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
            //All the things that we should put in this point.. I'm using the list14 example
        //HERE IS THE POLEMIC CODE
        if(position == itemSelected)
            convertView.setBackgroundColor(R.color.rojo);
        else
            convertView.setBackgroundColor(R.color.blanco);

        return convertView;

}
}

La setBackgroundColor() la méthode ne fonctionne pas. Je sais que c'est de faire quelque chose parce que quand j'utilise cette méthode, la couleur d'arrière-plan de la touche point les modifications apportées à une version opaque de la couleur par défaut lorsqu'un élément de liste est pressé.

Ce problème ne se produit qu'avec la couleur d'arrière-plan, je peux changer tout le reste, sans problèmes...

Merci!

OriginalL'auteur Desenfoque | 2011-11-09