When creating layouts programmatically, you need to provide the parent container with layout instructions for the child.
// child element LinearLayout mainRowLayout = new LinearLayout(this); // parent element TableRow tr = new TableRow(this); // parent element instructions (layout params for main row) TableRow.LayoutParams lopForMainRow = new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tr.addView(mainRowLayout, lopForMainRow);
Release it:]
ataulm
source share