2013年9月1日星期日

Android TableRow dynamic layout, control does not display

TableRow inside the ListView dynamic layout with the code after the control is not displayed, this is why

AdapterItem in
code is as follows:

public AdapterItem (Context con, int screenWidth)
{
line = new LinearLayout (con);
line.setOrientation (LinearLayout.HORIZONTAL);
table = new TableLayout (con);

row1 = new TableRow (con);
row2 = new TableRow (con);

this.compName = new TextView (con);
cParam = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
cParam.addRule (RelativeLayout.ALIGN_PARENT_LEFT);

row2.addView (compName, cParam) ;/ / put cParam can go after the show ompName

row1.setMinimumWidth (300);
row2.setMinimumWidth (200);

table.addView (row1);
table.addView (row2);

line.addView (table);
line.addView (img, imgParam);
line.setMinimumHeight (100);
line.setMinimumWidth (screenWidth);
}
------ Solution ----------------------------------- ---------
access points come :)
in the end what is the problem that way?
------ Solution ---------------------------------------- ----
talk about the reasons ah, otherwise this is not garbage stickers
------ reference ---------------------- -----------------
own solution, lx to pick points it
------ reference ----------- ----------------------------
cParam = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams. WRAP_CONTENT);
cParam.addRule (RelativeLayout.ALIGN_PARENT_LEFT);

row2.addView (compName, cParam) ;/ / put cParam can go after the show ompName

here only with TalbleRow.LayouParams, can not be used RelativeLayout.LayoutParams
------ reference ----------------------- ----------------
Oh, so, Andrews learned to know the layout of the sub-objects are some attributes associated with the parent object using code control layout really a headache!

没有评论:

发表评论