How To Dynamically Set Layout Parameters In Android?
I have these text fields which I generated dynamically. But I can't seem to set layout parameters for them. Please tell me what I'm doing wrong. I'm able to generate the fields wit
Solution 1:
You are adding Table Row into table so use TableLayout.LayoutParams
instead of LinearLayout.LayoutParams
.As we use LayoutParam according to parent in which we are going to add
Solution 2:
You have to use TableRow.LayoutParams instead of LinearLayout.LayoutParams
Replace your code
LinearLayout.LayoutParamsfieldparams=newLinearLayout.LayoutParams(10, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
with the below code.
TableRow.LayoutParamsfieldparams=newTableRow.LayoutParams(10, TableRow.LayoutParams.WRAP_CONTENT, 1.0f);
Its working fine. Let me know what happened. :-)
Post a Comment for "How To Dynamically Set Layout Parameters In Android?"