如何在Android中显示多列ListView?

时间:2012-07-16 02:52:45

标签: android listview

我有一个Android应用程序,显示一个列表视图,显示:

一个

2

3

4

但我希望以下列格式显示:

一两个

三四

我该怎么办?

2 个答案:

答案 0 :(得分:1)

GridView是解决您问题的方法。请遵循此tutorial

答案 1 :(得分:0)

首先,您应该维护一个单独的xml文件,以便在Android中的 listview 中显示任何类型的输出。

对于多列列表视图,xml文件将是

 <?xml version="1.0" encoding="utf-8"?>
 <!-- row.xml -->
 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:paddingTop="4dip"
 android:paddingBottom="6dip"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:orientation="horizontal">

 <TextView android:id="@+id/TRAIN_CELL"
     android:layout_width="50dip"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/TO_CELL"
     android:layout_width="60dip"
     android:layout_height="wrap_content"  android:layout_weight="1"/>
</LinearLayout>

Here就是你要找的例子。有关实现多列列表视图的完整教程,您可以查看this

祝你好运