Code example for TableRow

Methods: addView, ViewGroup.addView, setAlpha, setBackgroundColor, setLayoutParams, setTag

0
 
	public void addItemToView(ItemWithQuantity item) {
 
		if(null != item) {
	        TableLayout table = (TableLayout) findViewById(R.id.basketTable);
	        TableRow row = new TableRow(this);
	        row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
	        row.setBackgroundColor(Color.parseColor("#EDE8EA"));
	        row.setAlpha(.85f);
	        row.setTag(BASKET_ROW_TAG);
	        row.addView(getTextView("#"+item.getQuantity()));
	       	row.addView(getTextView(item.getItem().getName()));
	       	row.addView(getTextView(item.getItem().getInfo().getPer100g().getCalories()));
	       	row.addView(getTextView("\u00A3"+item.getItem().getPrice().divide(BigDecimal.valueOf(100))));
	       	row.addView(getButton());
	       	table.addView(row);
		} 
    } 
 
    private View getImageView(String imageUrl) {