<ListView android:id="@+id/SCHEDULE" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ListView>
<?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/FROM_CELL" android:layout_width="70dip" android:layout_height="wrap_content" android:layout_weight="1"/> <TextView android:id="@+id/TO_CELL" android:layout_width="60dip" android:layout_height="wrap_content" android:layout_weight="1"/> </LinearLayout>
ListView list = (ListView) findViewById(R.id.SCHEDULE);
ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
map.put("train", "101");
map.put("from", "6:30 AM");
map.put("to", "7:40 AM");
mylist.add(map);
map = new HashMap<String, String>();
map.put("train", "103(x)");
map.put("from", "6:35 AM");
map.put("to", "7:45 AM");
mylist.add(map);
// ...
mSchedule = new SimpleAdapter(this, mylist, R.layout.row,
new String[] {"train", "from", "to"}, new int[] {R.id.TRAIN_CELL, R.id.FROM_CELL, R.id.TO_CELL});
list.setAdapter(mSchedule);