我有以下代码:使用的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