compguru910
Lurker
I have been searching for hours on how to do this, but cant seem to find anything on it. Im connecting to a database and pulling down information into my app, and for each row, im adding a tablerow, and putting views into it. That parts fine, but the actual layout of the views is whats getting to me. I cant seem to find out what to use to control the layout. This is what I got
Code:
[SIZE=2]TableLayout tl = (TableLayout)findViewById(R.id.[/SIZE]
[LEFT][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]table_layout[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]for[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] i=0; i<jArray.length(); i++){[/SIZE]
[LEFT][SIZE=2]JSONObject jData = jArray.getJSONObject(i);[/SIZE]
[SIZE=2]TableRow tr = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TableRow([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]tr.setLayoutParams([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] LayoutParams([/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FILL_PARENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],[/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[SIZE=2]TextView text = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TextView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]text.setText(jData.getString([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"title"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]));[/SIZE]
[SIZE=2]text.setLayoutParams([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] LayoutParams([/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FILL_PARENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],[/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[SIZE=2]ImageView image = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] ImageView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]image.setImageResource(R.drawable.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]cslogo[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]image.setLayoutParams([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] LayoutParams(75,75));[/SIZE]
[LEFT][SIZE=2]tr.addView(image);[/SIZE][/LEFT]
[/LEFT]
[LEFT][SIZE=2]TextView text2 = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TextView([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[LEFT][SIZE=2]text2.setText(jData.getString([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"description"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]));[/SIZE]
[SIZE=2]text.setLayoutParams([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] LayoutParams([/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FILL_PARENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE]
[SIZE=2]tr.addView(text2);[/SIZE]
[SIZE=2]tr.addView(text);[/SIZE]
[SIZE=2]tl.addView(tr, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] TableLayout.LayoutParams([/SIZE]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]FILL_PARENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],[/SIZE][/LEFT]
[SIZE=2]LayoutParams.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]WRAP_CONTENT[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]));[/SIZE][/LEFT]
And of course, when that propagates, the textviews are out of order. The image is in the right spot, but the text isnt. I want the title text over the image and description, then the image on the left, then the description text next to the image on the right. I would be in a good shape if I could get that to work. In addition to that, how do you edit to the color and size text progmattically?