java 代码: package ListTest.abc; import android.app.Activity; import android.os.Bundle; import android.view.*; import java.util.*; import android.widget.ListView; import android.widget.SimpleAdapter; public class ListTestActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView lv = (ListView)findViewById(R.id.ListView01); // 列表控件的数据 ArrayList<HashMap<String, Object>> listitems = new ArrayList<HashMap<String, Object>>(); for(int i=0;i<20;i++){ HashMap<String, Object> map = new HashMap<String, Object>(); map.put("ItemTitle", "Title " + i); map.put("ItemText", "Text " +i); listitems.add(map); } // 列表控件的适配器,用于连接数据与控件 SimpleAdapter adapter = new SimpleAdapter(this, listitems, R.layout.list_item, new String[]{"ItemTitle", "ItemText"}, new int[]{R.id.ItemTitle, R.id.ItemText} ); // 设置列表控件的适配器 lv.setAdapter(adapter); } } 自定义列表控件的项模板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="wrap_content" android:orientation="vertical"> <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="ItemTitle" android:id="@+id/ItemTitle"></TextView> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="ItemText" android:id="@+id/ItemText"></TextView> </LinearLayout>