Ich habe eine Liste von einer SQLite-Datenbank gefüllt und funktioniert gut, aber ich möchte ein Bild neben dem Text ausfüllen.Hinzufügen von Bildern zu einer ListView
Also im Moment zeigt die ListView die Zeichen Namen. Ich möchte ein anderes Feld bekommen, wenn dieses Feld gleich x ist, setze Bild x sonst, wenn dieses Feld gleich y Bild y zeigt.
Kann ich Bilder mit meiner aktuellen Implementierung hinzufügen?
listContent = (ListView) findViewById(R.id.contentlist);
mDbAdapter = new DbAdapter(this);
mDbAdapter.open();
Cursor cursor = mDbAdapter.fetchAll();
startManagingCursor(cursor);
String[] from = new String[] { DbAdapter.KEY_NAME };
int[] to = new int[] { R.id.text };
cursorAdapter = new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
listContent.setAdapter(cursorAdapter);
mDbAdapter.close();
Und heren die xml
<ImageView
android:id="@+id/icon"
android:layout_gravity="left"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="5dp" />
<TextView
android:id="@+id/text"
android:text="Name"
android:paddingLeft="10dip"
android:layout_weight="0.5"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:padding="5dp" />
</LinearLayout>