ListView 2 lignes et l'icône d'un élément par Élément dans Android

Hy,
Je veux ajouter une icône et 2 lignes dans un élément de Liste. Les premières seront les valeurs et la deuxième sera values2

String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2" };
String[] values2 = new String[] `enter code here`{ "Android2", "iPhone2",        "WindowsMobile2",
            "Blackberry2", "WebOS2", "Ubuntu2", "Windows72", "Max OS  X2",
            "Linux2", "OS/22" };

Mon xml de la liste est :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<ListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
</ListView>

</LinearLayout>

Mon xml pour chaque ligne est :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ImageView
    android:id="@+id/icon"
    android:layout_width="22px"
    android:layout_height="22px"
    android:layout_marginLeft="4px"
    android:layout_marginRight="10px"
    android:layout_marginTop="4px"
    android:src="@drawable/ic_launcher" >
</ImageView>

<TextView
    android:id="@+id/label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@+id/label"
    android:textSize="20px" />

<TextView
    android:id="@+id/label2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@+id/label" />

</LinearLayout>

Et mon code est :

 public class listaNoua extends ListActivity {
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
            "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
            "Linux", "OS/2" };
    String[] values2 = new String[] { "Android2", "iPhone2", "WindowsMobile2",
            "Blackberry2", "WebOS2", "Ubuntu2", "Windows72", "Max OS X2",
            "Linux2", "OS/22" };

    ArrayAdapter<String> adapter = new ArrayAdapter<String>  (this,R.layout.rowlayout, R.id.label2, values2);
    setListAdapter(adapter);

}

Si j'ajoute :

   ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.rowlayout,   R.id.label2, values2 , R.id.label, values);

Le code ne fonctionne pas

Quelqu'un peut-il m'aider ?

voir simplelistadapter pour les plus complexes de liaison (essentiellement d'une liste d'identifiants et d'une liste d'éléments (bien que cela fonctionne sur les curseurs seulement, ce qui impliquerait l'utilisation d'un matrixcursor quelque part)

OriginalL'auteur Razvan | 2012-01-05