2010-11-16 68 views
0

我遇到問題在活動內部創建一個tablelayout。到目前爲止,我設法使用textview顯示結果查詢。幫助在.java內創建TableLayout活動

((TextView) view.findViewById(R.id.tv_id)).setText(listItem.getId()+""); 
((TextView) view.findViewById(R.id.tv_name)).setText(listItem.getName()); 
((TextView) view.findViewById(R.id.tv_age)).setText(listItem.getAge()+""); 

我將不勝感激,如果你能幫我把這個textview變成tablelayout。

感謝您的幫助

回答

0

您需要在佈局xml中執行此操作。如果是這種活動的唯一輸出的XML看起來像:

<Table_Layout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:stretch_columns="*"> 

<TableRow> 
<TextView 
android:id="@+/tv_id" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent"/> 
<TextView 
android:id="@+/tv_name" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent"/> 
<TextView 
android:id="@+/tv_age" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent"/> 
</TableRow> 

</Table_Layout> 

是否會有更多的行包這一切在一個滾動型,因此用戶界面是滾動的。