我有以下代碼:使用的RelativeLayout的佈局一個ListView
public class Events extends ListActivity {
//...
private static String[] FROM = {_ID,TIME,TITLE};
private static int[] TO = {R.id.rowid,R.id.time,R.id.title,};
private void showEvents(Cursor cursor) {
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, FROM, TO);
setListAdapter(adapter);
}
}
的R.layout.item的定義是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/rowid"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/rowidcolon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=": "
android:layout_toRightOf="@id/rowid" />
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@id/rowidcolon" />
<TextView
android:id="@+id/timecolon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=": "
android:layout_toRightOf="@id/time" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:singleLine="true"
android:textStyle="italic"
android:layout_toRightOf="@id/timecolon" />
</RelativeLayout>
所以我的問題是,當我運行這個程序,列表中唯一顯示的就是行ID textview。顯示後沒有任何文字視圖。有誰知道如何解決這一問題?謝謝。
謝謝,這正是我正在尋找的解決方案。 – PsychoMantis 2011-03-12 20:30:34