
ensacom
Ambitioniertes Mitglied
- 6
Hallo, ich lese mehrere Werte aus einer SQLite Datenbank aus und füge die in eine ListView ein.
Kann mir einer sagen wie ich je nach Status (Fahrzeugart privat, dienstlich) ein anderes Symbol vor jeden Eintrag in der ListView bekomme?
Hier mein source
fahrzeuge.java
fahrzeuge.xml
Kann mir einer sagen wie ich je nach Status (Fahrzeugart privat, dienstlich) ein anderes Symbol vor jeden Eintrag in der ListView bekomme?
Hier mein source
fahrzeuge.java
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
getListView().setOnCreateContextMenuListener(this);
myDB = this.openOrCreateDatabase(TankPro2.MY_DATABASE_NAME, MODE_PRIVATE, null);
Cursor c = myDB.rawQuery("SELECT _id, name || ', ' || model as bezeichnung, tankinhalt FROM " + TankPro2.MY_DATABASE_TABLE, null);
startManagingCursor(c);
final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
R.layout.fahrzeuge,
c,
new String[] { "_id" },
new int[] { R.id.KfzNameModel });
adapter.setViewBinder(new ViewBinder()
{
@Override
public boolean setViewValue(View view, Cursor theCursor, int column)
{
final String ColNameModel = theCursor.getString(1); //Name und Model
((TextView)view).setText(ColNameModel);
return true;
}
});
this.setListAdapter(adapter);
}
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/KfzNameModel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10px"
android:textStyle="bold" android:textSize="24px">
</TextView>
</LinearLayout>
Vielen Dank