Android First Tablerow Is Not Showing
Solution 1:
Some more info. I managed to display the buttons, further debug showed that setting the Layout params for each button in the function getColumnHeader() caused the problem. Still I don't know why. The button member mLayoutParams being null is OK, but when created (.setLAyoutParams()) and assigned values (for example width and height) the suddenly the button is not displayed. This is the patch,... until I figure out why.
privateButtongetColumnHeader(String name) {
Button bt = newButton(getContext());
//LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);//params.rightMargin = params.leftMargin = 2;//bt.setLayoutParams(params);
bt.setText(name);
return bt;
}
Solution 2:
Last piece of the puzzle. I tried many variations and finally it worked! Replacing LayoutParams with TableRow.LayoutParams did the trick. Their structure is very similar, probably even TableRow.LayoutParams is derived from LayoutParams. I will leave the mystery here, until some expert sheds light on why this happened. The final code:
private ButtongetColumnHeader(String name) {
Button bt = newButton(getContext());
TableRow.LayoutParams params = newTableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.MATCH_PARENT);
params.rightMargin = params.leftMargin = 2;
bt.setLayoutParams(params);
bt.setText(name);
return bt;
}
Post a Comment for "Android First Tablerow Is Not Showing"