0
在我的android應用程序中,我需要在運行時加載TableLayout
。我已經實現了一種從SQLite數據庫檢索數據的方法,該數據庫返回一個ArrayList
。我想要做的是如何在運行時在TableLayout
中加載這些檢索到的數據?我需要爲它編寫一個單獨的方法。在我的xml文件中,我已經定義瞭如下的TableLayout
。我需要在這個TableLayout
加載表格數據。如果有人能夠如此友好地解釋我該如何做到這一點,我會非常感激。Android:在運行時加載表數據
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarSize="5dp"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableLayout
android:id="@+id/tblPersons"
android:layout_width="fill_parent"
android:layout_height="match_parent" >
</TableLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
提前感謝名單
雖然這當然是可以的,但請考慮使用ListView來顯示數據列表。 ListViews是爲了這樣的事情。 –
'foreach elem in array {inflate tablerow;用elem中的數據設置表格字段; tblPersons.addView(tablerow的); }但像Ken寫ListView是更好的選擇 – Selvin