Code example for TableRow

Methods: addView, setBackgroundColor, setGravity, setLayoutParams

0
						null, null); 
		try { 
			if (cur != null && cur.moveToFirst()) {
 
				do { 
					row = new TableRow(this);
					row.setBackgroundColor(Color.TRANSPARENT);
 
					name = new TextView(this);
					name.setBackgroundColor(Color.parseColor("#000000"));
					name.setWidth(100);
					LayoutParams params = new LayoutParams();
					params.setMargins(1, 1, 1, 1);
					name.setLayoutParams(params);
					name.setGravity(Gravity.CENTER_HORIZONTAL);
 
					movebonus = new TextView(this);
					movebonus.setBackgroundColor(Color.parseColor("#000000"));
					movebonus.setLayoutParams(params);
					movebonus.setGravity(Gravity.CENTER_HORIZONTAL);
 
					timebonus = new TextView(this);
					timebonus.setBackgroundColor(Color.parseColor("#000000"));
					timebonus.setLayoutParams(params);
					timebonus.setGravity(Gravity.CENTER_HORIZONTAL);
 
					guessbonus = new TextView(this);
					guessbonus.setBackgroundColor(Color.parseColor("#000000"));
					guessbonus.setLayoutParams(params);
					guessbonus.setGravity(Gravity.CENTER_HORIZONTAL);
 
					total = new TextView(this);
					total.setBackgroundColor(Color.parseColor("#000000"));
					total.setLayoutParams(params);
					total.setGravity(Gravity.CENTER_HORIZONTAL);
 
					row.setGravity(Gravity.CENTER);
					row.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
 
					name.setText(""
							+ cur.getString(cur
									.getColumnIndex(ContentDescriptor.Highscore.Column.PLAYERNAME)));
					name.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
					row.addView(name);
 
					movebonus
							.setText(""
									+ cur.getInt(cur
											.getColumnIndex(ContentDescriptor.Highscore.Column.MOVEBONUS)));
					movebonus.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
					row.addView(movebonus);
 
					timebonus
							.setText(""
									+ cur.getInt(cur
											.getColumnIndex(ContentDescriptor.Highscore.Column.TIMEBONUS)));
					timebonus.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
					row.addView(timebonus);
 
					guessbonus
							.setText(""
									+ cur.getInt(cur
											.getColumnIndex(ContentDescriptor.Highscore.Column.GUESSBONUS)));
					guessbonus.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
					row.addView(guessbonus);
 
					total.setText(""
							+ cur.getInt(cur
									.getColumnIndex(ContentDescriptor.Highscore.Column.TOTALPOINTS)));
					total.setLayoutParams(new TableRow.LayoutParams(
							TableRow.LayoutParams.MATCH_PARENT,
							TableRow.LayoutParams.WRAP_CONTENT));
					row.addView(total);
 
					highscoreTable.addView(row, new TableLayout.LayoutParams(
							LayoutParams.MATCH_PARENT,
							LayoutParams.WRAP_CONTENT));
				} while (cur.moveToNext());