Code example for TableRow

Methods: addView, setId, setLayoutParams

0
			Integer index3 = cursor.getColumnIndex("up_down");
 
			if (cursor.getCount() > 0) {
				cursor.moveToFirst();
				do { 
					row = new TableRow(this);
					row.setId(100);
					row.setLayoutParams(new LayoutParams(
							LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
 
					/* Setting up the first coloumn parameters */ 
					vehicle = new TextView(this);
					vehicle.setText(cursor.getString(index0));
					vehicle.setTextSize(16);
					vehicle.setPadding(0, 5, 5, 0);
					vehicle.setLayoutParams(new LayoutParams(
							LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
					row.addView(vehicle); // adding coloumn to row
 
					/* Setting up the second coloumn parameters */ 
					date = new TextView(this);
					date.setText(cursor.getString(index1));
					date.setPadding(0, 5, 5, 0);
					date.setTextSize(16);
					date.setLayoutParams(new LayoutParams(
							LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
					row.addView(date); // adding coloumn to row
 
					/* Setting up the third coloumn parameters */ 
					time = new TextView(this);
					time.setText(cursor.getString(index2));
					time.setPadding(0, 5, 5, 0);
					time.setTextSize(16);
					time.setLayoutParams(new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
					row.addView(time); // adding coloumn to row
					/* Setting up the fourth coloumn parameters */ 
					count = new TextView(this);
					count.setText("1");
					count.setPadding(0, 5, 5, 0);
					count.setTextSize(16);
					count.setLayoutParams(new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
					row.addView(count); // adding coloumn to row
 
					/* Setting up the fourth coloumn parameters */ 
					updown = new TextView(this);
					updown.setText(cursor.getString(index3));
					updown.setPadding(0, 5, 5, 0);
					updown.setTextSize(16);
					updown.setLayoutParams(new LayoutParams(
							LayoutParams.WRAP_CONTENT,
							LayoutParams.WRAP_CONTENT));
					row.addView(updown); // adding coloumn to row
 
					/* Adding the row to the tablelayout */ 
					tableLayout.addView(row,
							new TableLayout.LayoutParams(
									LayoutParams.FILL_PARENT,