테이블 레이아웃 동적으로 할당받는 부분인데요 .
레이아웃에 아무것도 들어가질 않네요 ...
public void drawTable2()
{
for(int i=0;i<5;i++)
{
Log.i("tag", "Sequence : " + i);
TableLayout table = (TableLayout)findViewById(R.id.myTable);
TableRow tmp = null;
for(int j=0;j<4;j++)
{
TextView tv = new TextView(this);
TableRow row = new TableRow(this);
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
tv.setText("hello");
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
tv.setGravity(Gravity.CENTER);
tv.setBackgroundColor(0xFFFFFFFF);
row.addView(tv);
tmp = row;
}
table.addView(tmp,new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
tmp = null;
}
}
------------------------------------------------------------------------------------------
XML
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
</TableLayout>
http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout
*Please note that you must "import android.widget.TableRow.LayoutParams" and NOT 'import android.widget.TableLayout.LayoutParams' or another LayoutParams class. If you use the wrong LayoutParams class, then the rows won't be shown probably.
import android.widget.TableRow.LayoutParams;
외 다른 LayoutParams 참조는 주석처리하시면 됩니다.