ListAdapter / Cursor,Android。自定义布局问题

时间:2010-10-12 21:27:14

标签: java android xml

我正在试验Android平台,我开始喜欢它,但是现在我被卡住了,在这个光标/列表适配器问题上。 问题是,我请求一个函数,返回一个数据对象,我想要映射到不同的TextView的几个属性。

我的 list_item.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">
    <TextView android:id="@+id/schedule_item_text"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dp"
        android:textSize="16sp" />
    <TableRow android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1">
        <TableRow>
            <TextView android:layout_column="1" android:text="teacher" android:padding="3dip"/>
            <TextView android:gravity="right" android:text="Test" android:padding="3dip" />
        </TableRow>
    </TableRow>
</LinearLayout>

所以我想做的是:将对象数组的属性映射到文件中的多个字段。怎么样?帮助

1 个答案:

答案 0 :(得分:0)

您可能希望使用SimpleAdapter作为ListView适配器。它允许您将对象中的字段映射到布局中的特定小部件。

这方面有很多教程,例如my first meeting with simple adapter