I'm experimenting with the Android platform, and I'm beginning to love it, but right now I'm stuck, at this cursor/list adapter problem-thing. The thing is, that I request a function, returning a data object, with several properties I'd like to map to different TextView's.
My 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_w开发者_Go百科idth="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>
So what I would like to do is: Map a property of an array of objects to several fields in the file. How? Help?
You might want to look into using a SimpleAdapter as your ListView adapter. It allows you to map a field in your object into a particular widget in your layout.
There are a number of tutorials on this around, for example my first meeting with simple adapter.
精彩评论