帮助在 .java 活动中创建 TableLayout

发布于 2024-10-02 16:46:59 字数 358 浏览 0 评论 0原文

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

( (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()+"" );

如果您能帮我将此文本视图转换为表格布局,我将不胜感激。

感谢您的帮助

I am having problem create a tablelayout inside an activity. So far i managed to display the resulting query using 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()+"" );

i would appreciate it if you can help me turn this textview into tablelayout.

thanks for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无声情话 2024-10-09 16:46:59

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

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

You need to do this in the layout xml. If this is the only output of the activity the xml would look something like:

<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>

If there will be more rows wrap it all in a ScrollView so the ui is scrollable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文