J'utilise ce code pour mon simple, ListView maintenant:Comment faire ListView avec CheckBox et Image?
final ListView lv = (ListView)findViewById(R.id.apps_list);
lv.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, myString.split("\n")));
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
}
});
et mise en page:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:id="@+id/separator_apps"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/apps" />
<ListView
android:id="@+id/apps_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/separator_apps" >
</ListView>
</RelativeLayout>
Mais je dois ajouter une image et CheckBox à chaque ligne de CE ListView, quelqu'un pourrait me donner un bon exemple?
http://www.vogella.de/articles/AndroidListView/article.html –
référez-vous à ceci: http: //stackoverflow.com/questions/4797926/how-to-make-a-listactivity-with- custom-list-item-with-nested-clickable-button.Il est similaire à votre problème.vous avez juste besoin de remplacer le bouton par case à cocher et TextView par image. – Hiral
Merci, je vais le regarder. – Adam