I have the following code:
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);
}
}
The R.layout.item is defined as such:
<?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>
So my problem is that when I run this program, the only thing that is displayed in the list is the Row ID textview. None of the text views that come after it are displayed. Does anyone know how to fix this? Thanks.
The
tell the row id TextView to be the same size as the parent RelativeLayout. If you want all the TextViews to be laid out horizontally you should use a LinearLayout as the parent, and set
android:orientation="horizontal".