| |||||||
Das Thema "SQL-Daten in Listview mit Titel anzeigen" befindet sich unter Android App Entwicklung auf Android-Hilfe.de.
|
| | Themen-Optionen | Ansicht |
| | #1 (permalink) |
| Junior Mitglied Registriert seit: 22.06.2010
Beiträge: 37
Abgegebene Danke: 3
Erhielt 0 Danke für 0 Beiträge
| ich möchte Daten aus einer SQL-Datenbank darstellen und benutze dazu eine Activity, die von ListActivity abgeleitet ist und einen SimpleCursorAdapter. Passt soweit alles super, nur bekomme ich keine vernünftige Spaltenüberschriften hin. Das Layout (siehe unten) ist zweizeilig und hat 2 bzw. 3 Spalten. Ich habe ein Layout für die Form definiert und ein weiteres als Relative Layout für die Spalten der DB. Ideal wäre es, ich könnte das Layout für einen Datensatz auch als Überschrift nutzen, dann würden die Anordnungen gleich passen. Mein Versuch, mit einem Include das LAyout einzubinden, ging leider gar nicht. Aktuell gebe ich nur 2 Textviews als Header aus: Bezeichnung Status -------------------------------------- Liste Menü offen Startseite 12 Ziel wäre z.B.: Typ Bezeichnung Status Modus ID -------------------------------------- Liste Menü offen Startseite 12 Wie kann ich so ein Layout umsezten? Die Daten weise ich hier zu: Code: private void fillData() {
cursor = myDataBase.fetchAllPreloadData();
startManagingCursor(cursor);
String[] from = new String[] { DB.prelo_ID, DB.prelo_TYP, // DB.prelo_SessionID,
DB.prelo_FlagStatus, DB.prelo_HybridModell,
DB.prelo_NameDialog };
int[] to = new int[] { R.id.galDatID, R.id.galDatTyp,
R.id.galDatStatus, R.id.galDatHybrid, R.id.galDatName };
// Now create an array adapter and set it to display using our row
SimpleCursorAdapter notes = new SimpleCursorAdapter(this,
R.layout.form_gallerydatarow, cursor, from, to);
setListAdapter(notes);
} 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"
android:background="@color/listBgColor">
<TextView android:id="@+id/galDatTitel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/red"
android:text="@string/fgdTitleName" />
<TextView android:id="@+id/galDatTitel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:text="@string/fgdTitleStatus" />
<ImageView android:id="@+id/filler"
android:layout_width="fill_parent"
android:layout_height="2px"
android:background="@color/listTitleSeparatorColor" />
<ListView android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
android:drawSelectorOnTop="true"/>
</ListView>
<TextView android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/fgdIsEmpty" />
</LinearLayout> Code: <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/form_galdata_relative_row"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:layout_height="wrap_content"
android:layout_width="60dip"
android:layout_toRightOf="@+id/imageView1"
android:text="TextView"
android:id="@+id/galDatTyp"
android:textColor="@color/red"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_toRightOf="@+id/galDatTyp"
android:paddingLeft="6px"
android:text="TextView"
android:id="@+id/galDatName"
android:layout_alignParentRight="true"
android:textColor="@color/red"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_width="60dip"
android:layout_below="@+id/galDatTyp"
android:text="TextView"
android:id="@+id/galDatStatus"
android:textColor="@color/black"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingLeft="6px"
android:layout_toRightOf="@+id/galDatStatus"
android:layout_alignParentTop="@+id/galDatStatus"
android:layout_below="@+id/galDatName"
android:text="TextView"
android:paddingRight="2dip"
android:id="@+id/galDatHybrid"
android:textColor="@color/black"></TextView>
<TextView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_below="@+id/galDatName"
android:text="TextView"
android:id="@+id/galDatID"
android:textColor="@color/hidden"></TextView>
</RelativeLayout> Bitttteeee!!! |
| | |
![]() |
|
| Themen-Optionen | |
| Ansicht | |
| |
| ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| (SQL) Daten werden in ListActivity nicht angezeigt. | El_Rakiti | Android App Entwicklung | 4 | 16.02.2011 18:55 |
| Wie bekomme ich daten aus einer ListView? | MilesTeg | Android App Entwicklung | 2 | 04.12.2010 19:19 |
| Irgendetwas NEBEN ListView anzeigen | mdolphin | Android App Entwicklung | 2 | 30.11.2010 14:40 |
| ListView mit 2 Zeilen anzeigen aus xml | beginnerUser | Android App Entwicklung | 2 | 30.09.2010 21:31 |
| SQL Lite Datenbank + ListView | pgnonick | Android App Entwicklung | 26 | 28.08.2009 13:14 |