X
xdroid-man
Neues Mitglied
- 0
Hallo,
ich versuche einem im XML definiertem TabellenLayout programmatisch Tabellenzeilen (TableRow) hinzuzufügen. Den Tabellenzeilen möchte ich pro Zeile 3 Views hinzufügen, auch wieder programmatisch.
Die einzelnen Views sollen Bilder enthalten. Da die Bilder recht Groß sind wollte ich die View größentechnisch mit LayoutParams begrenzen aber ich scheitere immer. Wenn ich die Zeile
[FONT="]image.setLayoutParams(new LayoutParams(75, 75));
[/FONT]
[FONT="]
[/FONT]
einkommentiere sehe ich gar nichts. Lass ich die Zeile weg ist das Bild viel zu groß.
Ich würde mich über Hilfe freuen.
Grüße
ich versuche einem im XML definiertem TabellenLayout programmatisch Tabellenzeilen (TableRow) hinzuzufügen. Den Tabellenzeilen möchte ich pro Zeile 3 Views hinzufügen, auch wieder programmatisch.
Die einzelnen Views sollen Bilder enthalten. Da die Bilder recht Groß sind wollte ich die View größentechnisch mit LayoutParams begrenzen aber ich scheitere immer. Wenn ich die Zeile
[FONT="]image.setLayoutParams(new LayoutParams(75, 75));
[/FONT]
[FONT="]
[/FONT]
einkommentiere sehe ich gar nichts. Lass ich die Zeile weg ist das Bild viel zu groß.
Code:
[COLOR=#0000C0][FONT="]tableRow[/FONT][/COLOR][COLOR=black][FONT="] = [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]TableRow[/FONT][/COLOR][COLOR=black][FONT="]([/FONT][/COLOR][B][COLOR=#7F0055][FONT="]this[/FONT][/COLOR][/B][COLOR=black][FONT="]);[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]tableRow[/FONT][/COLOR][COLOR=black][FONT="].setLayoutParams([/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]LayoutParams[/FONT][/COLOR][COLOR=black][FONT="]([/FONT][/COLOR][COLOR=#9B009B][FONT="]LayoutParams[/FONT][/COLOR][COLOR=black][FONT="].[U]FILL_PARENT[/U], 75));[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT="]for[/FONT][/COLOR][/B][COLOR=black][FONT="]( [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]int[/FONT][/COLOR][/B][COLOR=black][FONT="] x = 0; x < pathesToImages.size() ; x++ )[/FONT][/COLOR]
[COLOR=black][FONT="] {[/FONT][/COLOR]
[COLOR=#9B009B][FONT="]Log[/FONT][/COLOR][COLOR=black][FONT="].[I]d[/I]([/FONT][/COLOR][COLOR=#2A00FF][FONT="]"Lars Koslowski"[/FONT][/COLOR][COLOR=black][FONT="],x + [/FONT][/COLOR][COLOR=#2A00FF][FONT="]": "[/FONT][/COLOR][COLOR=black][FONT="] + pathesToImages.get(x).toString());[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]image[/FONT][/COLOR][COLOR=black][FONT="] = [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]ImageView[/FONT][/COLOR][COLOR=black][FONT="]([/FONT][/COLOR][B][COLOR=#7F0055][FONT="]this[/FONT][/COLOR][/B][COLOR=black][FONT="]);[/FONT][/COLOR]
[COLOR=#3F7F5F][FONT="]//image.setLayoutParams(new LayoutParams(75, 75));[/FONT][/COLOR]
[COLOR=#9B009B][FONT="]File[/FONT][/COLOR][COLOR=black][FONT="] foto = [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]File[/FONT][/COLOR][COLOR=black][FONT="](pathesToImages.get(x).toString());[/FONT][/COLOR]
[COLOR=#9B009B][FONT="]BitmapFactory[/FONT][/COLOR][COLOR=black][FONT="].[/FONT][/COLOR][COLOR=#9B009B][FONT="]Options[/FONT][/COLOR][COLOR=black][FONT="] options = [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]
[/FONT][/COLOR]
[COLOR=#9B009B][FONT="]BitmapFactory[/FONT][/COLOR][COLOR=black][FONT="].[/FONT][/COLOR][COLOR=#9B009B][FONT="]Options[/FONT][/COLOR][COLOR=black][FONT="]();[/FONT][/COLOR]
[COLOR=#3F7F5F][FONT="]//options.inSampleSize = 2;[/FONT][/COLOR]
[COLOR=#9B009B][FONT="]Bitmap[/FONT][/COLOR][COLOR=black][FONT="] bitmap = [/FONT][/COLOR][COLOR=#9B009B][FONT="]BitmapFactory[/FONT][/COLOR][COLOR=black][FONT="].[I]decodeFile[/I](foto.getAbsolutePath(), options);[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]image[/FONT][/COLOR][COLOR=black][FONT="].setImageBitmap(bitmap);[/FONT][/COLOR][COLOR=#3F7F5F][FONT="]//setImageURI(Uri.fromFile([U]foto[/U]));[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]image[/FONT][/COLOR][COLOR=black][FONT="].setPadding(2, 2, 2, 2); [/FONT][/COLOR]
[COLOR=#0000C0][FONT="]tableRow[/FONT][/COLOR][COLOR=black][FONT="].addView([/FONT][/COLOR][COLOR=#0000C0][FONT="]image[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR]
[B][COLOR=#7F0055][FONT="]if[/FONT][/COLOR][/B][COLOR=black][FONT="] (x == 2)[/FONT][/COLOR]
[COLOR=black][FONT="] {[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]table[/FONT][/COLOR][COLOR=black][FONT="].addView([/FONT][/COLOR][COLOR=#0000C0][FONT="]tableRow[/FONT][/COLOR][COLOR=black][FONT="]);[/FONT][/COLOR]
[COLOR=#0000C0][FONT="]tableRow[/FONT][/COLOR][COLOR=black][FONT="] = [/FONT][/COLOR][B][COLOR=#7F0055][FONT="]new[/FONT][/COLOR][/B][COLOR=#9B009B][FONT="]TableRow[/FONT][/COLOR][COLOR=black][FONT="]([/FONT][/COLOR][B][COLOR=#7F0055][FONT="]this[/FONT][/COLOR][/B][COLOR=black][FONT="]);[/FONT][/COLOR]
[COLOR=black][FONT="] }[/FONT][/COLOR]
[COLOR=black][FONT="] }[/FONT][/COLOR]
Grüße