0
데이터가 서버에서오고, 테이블 레이아웃에 데이터를 표시하고 싶지만 서버에서 한 요청이있을 때 한 행을 표시하고 싶습니다. ...Tablelayout은 행 수를 하나씩 늘려야합니까?
데이터가 서버에서오고, 테이블 레이아웃에 데이터를 표시하고 싶지만 서버에서 한 요청이있을 때 한 행을 표시하고 싶습니다. ...Tablelayout은 행 수를 하나씩 늘려야합니까?
U 하나의 행보기가있는 TablLayout을 사용해야합니다. 귀하의 데이터.
XML :
<!-- THE DATA TABLE -->
<TableLayout
android:id="@+id/data_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:text="@string/th_id"
android:minWidth="50px"
/>
<TextView
android:text="@string/th_text_one"
android:minWidth="125px"
/>
<TextView
android:text="@string/th_text_two"
android:minWidth="125px"
/>
</TableRow>
</TableLayout>
등급 :
// the table that displays the data
TableLayout dataTable;
// THE DATA TABLE
dataTable=(TableLayout)findViewById(R.id.data_table);
/**
* updates the table from the database.
*/
private void updateTable()
{
// delete all but the first row. remember that the count
// starts at one and the index starts at zero
while (dataTable.getChildCount() > 1)
{
// while there are at least two rows in the table widget, delete
// the second row.
dataTable.removeViewAt(1);
}
// collect the current row information from the Server and
// store it in a two dimensional ArrayList
ArrayList<ArrayList<Object>> data = getAllRowsAsArrays();
// iterate the ArrayList, create new rows each time and add them
// to the table widget.
for (int position=0; position < data.size(); position++)
{
TableRow tableRow= new TableRow(this);
ArrayList<Object> row = data.get(position);
TextView idText = new TextView(this);
idText.setText(row.get(0).toString());
tableRow.addView(idText);
TextView textOne = new TextView(this);
textOne.setText(row.get(1).toString());
tableRow.addView(textOne);
TextView textTwo = new TextView(this);
textTwo.setText(row.get(2).toString());
tableRow.addView(textTwo);
dataTable.addView(tableRow);
}
}
나는 다시하려고 노력할 것이다. .. thx – MrSyntax
나쁜 생각 사용 목록보기. –
listView? 왜? 어느 것이 더 낫습니까? – MrSyntax