在Android中动态添加表行?
我只需要使用Java代码(而不是XML设计)添加表行 在该表行中,我必须添加两个textview字段。我使用下面的代码在Android中动态添加表行?,android,Android,我只需要使用Java代码(而不是XML设计)添加表行 在该表行中,我必须添加两个textview字段。我使用下面的代码 TableRow tblrow=new TableRow(this); tblrow.addView(Textview1); tblrow.addView(Textview2); 但它只显示Textview1。如何看待两者 我是Android新手。TableRow tr1; TableRow tr1; //TableRow tr2; TextView t
TableRow tblrow=new TableRow(this);
tblrow.addView(Textview1);
tblrow.addView(Textview2);
但它只显示Textview1。如何看待两者
我是Android新手。TableRow tr1;
TableRow tr1;
//TableRow tr2;
TextView txt9;
TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
LinearLayout.LayoutParams layoutParams =
new LinearLayout.LayoutParams(width, LayoutParams.FILL_PARENT);
for (int i = 0; i < str_arr.length-1; i++)
{
string_arr = fun1.split(str_arr[i].trim(),"^");
tr1 = (TableRow) new TableRow(this);
txt9=new TextView(this);
txt9.setText(strinarr[0]);
txt9.setBackgroundColor(intblue);
txt9.setTextColor(intwhite);
tr1.addView(txt9);
tl.addView(tr1,new TableLayout.LayoutParams(layoutParams));
}
//表行tr2;
TextView-txt9;
TableLayout tl=(TableLayout)findviewbyd(R.id.myTableLayout);
Display Display=getWindowManager().getDefaultDisplay();
int width=display.getWidth();
LinearLayout.LayoutParams LayoutParams=
新建LinearLayout.LayoutParams(宽度、LayoutParams.FILL\u父项);
对于(int i=0;i