Code example for TableRow

Methods: addView, addView, setLayoutParams

0
		 
		final String[] weekDays	= this._resources.getStringArray(array.WeekDays);
	} 
	 
	public void addRow() { 
		final TableRow	tr		= new TableRow(this);
		final TextView	tTime	= new TextView(this);
		final TextView	tDesc	= new TextView(this);
		 
		tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		 
		tTime.setText("Time");
		tTime.setTextColor(0xFFFFFFFF);
		tTime.setId(id.scheduler_time);
		 
		final LinearLayout.LayoutParams	tTimeParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		tTimeParams.setMargins(10, 0, 0, 0);
		tTime.setLayoutParams(tTimeParams);
 
		tDesc.setText("Description");
		tDesc.setTextColor(0xFFFFFFFF);
		tDesc.setId(id.scheduler_description);
		tDesc.setBackgroundResource(drawable.scheduler_task);
 
		tr.addView(tTime);
		tr.addView(tDesc);
		 
		((TableLayout) findViewById(id.schedulerLayout)).addView(tr,new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
	} 
 
} 
Contextual code suggestions in your IDE  Get Codota for Java