列在ListView的机器人 [英] Columns in ListView Android

查看:87
本文介绍了列在ListView的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何才能在Android中的ListView列?我有这个列表项目布局的xml:

How can I make columns in Android ListView? I have this list item layout xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="horizontal">
    <TextView android:layout_weight=".3" android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:id="@+id/hour"
        android:gravity="center" />
    <ImageView android:id="@+id/symbol" android:scaleType="fitCenter"
        android:layout_gravity="center_horizontal" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight=".5" />
    <TextView android:layout_weight=".8" android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:id="@+id/temperature"
        android:gravity="center" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:id="@+id/percipitation"
        android:gravity="center" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:id="@+id/wind_speed"
        android:gravity="center" />
    <TextView android:layout_weight="1" android:layout_width="wrap_content"
        android:layout_height="fill_parent" android:id="@+id/wind_direction"
        android:gravity="center" />
</LinearLayout>

问题是f.ex.时WIND_DIRECTION从4变为300,然后列未对准。

The problem is when the f.ex. wind_direction change from "4" to "300", then the columns are not aligned.

谁可以此与列的固定宽度,并采用全幅独立的设备制成的?

Who can this be made with fixed width of columns and using the whole width independent of devices?

推荐答案

考虑使用TableLayout,而不是一个ListView。这被设计成具有行和列。请参见您好TableLayout

Consider using a TableLayout instead of a ListView. This is designed to have rows and columns. See Hello TableLayout.

要编程添加行,你可以膨胀的TableRow,并呼吁addView在TableLayout。

To add rows programatically, you can inflate the TableRow and call addView on the TableLayout.

这篇关于列在ListView的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆