, . . , :
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_layout" >
</TableLayout>
TableLayout - ( ). TableRows, , , ? TableRow xml:
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tablerow_textview"
android:text="Hello" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tablerow_button"
android:text="World" />
</TableRow>
java. , 10 TableLayout . ( Context):
TableLayout layout = (TableLayout) findViewById(R.id.main_layout);
LayoutInflater inflater = LayoutInflater.from(this);
for(int i=0; i<10; i++)
{
TableRow row = (TableRow) inflater.inflate(R.layout.table_row, null);
Button rowButton = (Button) row.findViewById(R.id.tablerow_button);
TextView rowText = (TextView) row.findViewById(R.id.tablerow_textview);
an onClickListener, change the text, etc)
layout.addView(row);
}
, set-setter, , ,