dimanche 3 mai 2015

How to setImageResource in ListView Android?

I would like to setImageResource to my image in my listView

Here how the listView is shown with information :

       ListAdapter adapter = new SimpleAdapter(
               MainActivity.this,impatientEventList, R.layout.view_event_entry, new String[] {
               "title"
       }, new int[] {
               R.id.event_title
       });
        setListAdapter(adapter);

and my ListView entry :

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:src="@drawable/ic_launcher" />

<TextView
    android:id="@+id/event_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="23dp"
    android:layout_marginTop="10dp"
    android:layout_toRightOf="@+id/imageView1"
    android:text="Title"
    android:textSize="16sp"
    android:fontFamily="sans-serif-thin"/>

I don't really know how to put it when I use a List, anyone to help ? :) Thanks by advance!

Aucun commentaire:

Enregistrer un commentaire