Code example for TableRow

Methods: addView, setBackgroundColor, setLayoutParams

0
		 
		/* Split the string into words that can be set into columns */ 
		String[] splitString = stats.split(",");
		 
		/* New row object to pass back */ 
		TableRow tr = new TableRow(context);
		tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
		 
		 
		/* Iterate through the loop to set all the comma delimited data into separate columns */ 
		for(int i = 0; i < splitString.length; i++)
		{ 
			tv = new TextView(context);
			tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
			tv.setTextColor(Color.BLACK);
			tv.setText(splitString[i]);
			tr.addView(tv);
		} 
		 
		if(colourReverse % 2 == 0)
		{ 
			tr.setBackgroundColor(Color.WHITE);
		} 
		else 
		{ 
			tr.setBackgroundColor(Color.LTGRAY);
		} 
		colourReverse++;
 
		tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
		 
Connect your IDE to all the code out there  Get Codota for Java