Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 帮助在.java活动中创建TableLayout_Android_Android Activity_Tablelayout - Fatal编程技术网

Android 帮助在.java活动中创建TableLayout

Android 帮助在.java活动中创建TableLayout,android,android-activity,tablelayout,Android,Android Activity,Tablelayout,我在活动中创建表格布局时遇到问题。到目前为止,我设法使用textview显示结果查询 ( (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) ).setTe

我在活动中创建表格布局时遇到问题。到目前为止,我设法使用textview显示结果查询

( (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()+"" );
如果您能帮助我将此文本视图转换为表格布局,我将不胜感激


感谢您的帮助

您需要在布局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>

如果有更多的行,则将其全部包装在滚动视图中,以便ui可滚动