TableRows in ListView darstellen

Luebbi

Mitglied
Hallo

Ich habe ein Problem mit der Darstellung von TableRows in einem ListView.
Ich gehe so vor:
Zunächst erzeuge ich TableRows aus einem Layout, befülle die Spalten (TextViews)
und lade das TableRow in ein Array

Dem ListView ist ein ArrayAdapter zugewiesen, welcher mein TableRow-Array als Datenquelle hat.
GetView() habe ich überschrieben und gebe dort das verlangte TableRow aus dem Array zurück.
Das funktioniert soweit.

Aber:
Die Spalten sind nicht ausgerichtet, soll heißen, untereinander liegende Zellen
sind nicht in einer Linie sondern haben alle unterschiedliche Breiten.

Ein TableLayout passt die Breiten automatisch an. Geht das auch beim ListView?

Hier mein TableRow
Java:
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RowTitle"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


	<TextView
	    android:id="@+id/txtTitleRowTitle"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:paddingRight="20dp"
	    android:paddingTop="10dp"
	    android:text="@string/txtMediumText"
	    android:textAppearance="?android:attr/textAppearanceMedium" />
	
	<TextView
	    android:id="@+id/txtTitleRowVersion"
	    android:layout_width="wrap_content"
	    android:layout_height="wrap_content"
	    android:paddingRight="20dp"
	    android:paddingTop="10dp"
	    android:text="@string/txtMediumText"
	    android:textAppearance="?android:attr/textAppearanceMedium" />
	
</TableRow>

Viele Grüße
Lübbi
 

kurztipp

Aktives Mitglied
Hallo,

also wenn Deine TableRow nur zwei Elemente beinhaltetet, ist es bedeutend einfacher mit einem LinearLayout und weight oder einem RelativeLayout zu arbeiten. Wieso so umständlich?

Gruß
 

Luebbi

Mitglied
also wenn Deine TableRow nur zwei Elemente beinhaltetet, ist es bedeutend einfacher mit einem LinearLayout und weight oder einem RelativeLayout zu arbeiten. Wieso so umständlich?

Mir ging es ums Prinzip: Ich lade Daten dynamisch in ein TableRow-Vector, diese sollen als Tabelle in eine ListView angezeigt werden. Dabei sollen die Spalten so breit werden wie deren breitestes Element, und das soll automatisch geschehen.
Offenbar kann das nur das TableLayout. Innerhalb einer ListView scheit es nicht zu funktionieren. Deshalb werde ich beim TableLayout bleiben.

Viele Grüße
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
J ListView Item individuell einfärben Android & Cross-Platform Mobile Apps 17
I Android ListView, Werte aktualisieren ohne die Liste komplett neu zu laden Android & Cross-Platform Mobile Apps 5
W ListView OnItemClicklistener setzen mit Ausgabe Android & Cross-Platform Mobile Apps 35
K Null-Pointer-Exception in ListView - wird über Datenbank gefüllt Android & Cross-Platform Mobile Apps 1
I Android ListView (Custom) soll auf Hardwaretasten nicht reagieren. Android & Cross-Platform Mobile Apps 10
W ListView und Arrays... Android & Cross-Platform Mobile Apps 68
W Android Wieso kann ich keine ListView mehr zum Layout hinzufügen? Android & Cross-Platform Mobile Apps 1
W Android Kann keine ListView mehr in der MainActivtiy anzeigen, obwohl noch sehr viel Platz frei ist Android & Cross-Platform Mobile Apps 1
L ListView aktuallisiert sich nicht Android & Cross-Platform Mobile Apps 15
N Probleme mit custom dynamic ListView Android & Cross-Platform Mobile Apps 15
L Android ListView kollabiert in Scrollview Android & Cross-Platform Mobile Apps 9
A ImageButton in ListView Item bei klick ändern Android & Cross-Platform Mobile Apps 3
J Android Suche in einer ListView Android & Cross-Platform Mobile Apps 3
H Android ArrayList <-> ArrayAdapter <-> ListView Android & Cross-Platform Mobile Apps 10
L Android ListView swipe zum löschen Android & Cross-Platform Mobile Apps 1
B Android ListView set custom check Image and delete Android & Cross-Platform Mobile Apps 0
M Android ListView wird nicht dargestellt Android & Cross-Platform Mobile Apps 2
Maresuke Android Android ListView Textfarbe und Texthintergrund ändern? Android & Cross-Platform Mobile Apps 5
A Android Problem mit ListView und OnItemClickListener.. Android & Cross-Platform Mobile Apps 10
S Listview Einträge aus "xml" Datei Android & Cross-Platform Mobile Apps 1
S Android Studio MySql Daten in Listview mit sub Item Android & Cross-Platform Mobile Apps 11
S Textdatei in ListView einlesen Tutorial gesucht!? Android & Cross-Platform Mobile Apps 3
kaoZ Tutorial .xml Layouting für z.B ListView elemente Android & Cross-Platform Mobile Apps 7
M Android ListView und Checkbox Android & Cross-Platform Mobile Apps 6
M ListView mit ListAdapter füllen Android & Cross-Platform Mobile Apps 5
U Android ListView Frage Android & Cross-Platform Mobile Apps 6
L Android SearchBox für Custom Listview Android & Cross-Platform Mobile Apps 5
H Android ListView Images aus dem Internet via Thread Android & Cross-Platform Mobile Apps 3
T Android: ListView-Adapter: Adapter wird ständig aufgerufen Android & Cross-Platform Mobile Apps 2
H Android SAX|ListView NullPointerException Android & Cross-Platform Mobile Apps 2
A Probleme mit ListView / ArrayAdapter Android & Cross-Platform Mobile Apps 3
M Umlaute im Quellcode einer Website richtig darstellen Android & Cross-Platform Mobile Apps 4
C Android Listen/Daten aus der SQLLite Datenbank darstellen Android & Cross-Platform Mobile Apps 2
T Android Kontakte auslesen und in Liste darstellen Android & Cross-Platform Mobile Apps 8

Ähnliche Java Themen

Neue Themen


Oben