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