【发布时间】:2013-03-08 15:46:20
【问题描述】:
我有一个列表活动,它将显示人员姓名和地址列表以及对象数组列表中的数据。这是到目前为止填充列表视图的方法..
private void fillData(ArrayList<Person> messages) {
//populating list should go here
}
person 类存储一个人的姓名和地址。
public class Person {
String name;
String address;
}
虽然我的列表视图的列表项由两个文本视图组成,如下所示:
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:mode="twoLine"
android:clickable="false"
android:paddingBottom="9dp"
android:paddingTop="5dp" >
<TextView
android:id="@+id/display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/display_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/display_name"
android:layout_below="@+id/display_name"
android:textAppearance="?android:attr/textAppearanceSmall" />
我希望列表视图中的每个项目都显示每个人的姓名和地址。有人可以帮忙吗?
提前致谢,抱歉我的英语不好...
【问题讨论】:
-
在谷歌自定义列表视图中搜索...
-
您可以使用
onCreate方法。在这种情况下,它可以在程序中使用。
标签: android listview listactivity