I am writing an appointments application with a customised Listview. The ListView consists of a
- View, whose colour indicates priority
- Checkbox, to select the item with.
- DateText, to show what date the appointment is
- MonthText, to show what month the appointment is
- TimeText, to show when the appointment is
- Title, which stores the summary of the appointment
Each row in the listView should look something like this:

But only two widgets are visible: DateText and MonthText. The rest are not. Why is this the case?

My XML and getView() method are below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="@+id/priorityView"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:background="#cccccc"
android:layout_alignParentLeft="true" />
<CheckBox
android:id="@+id/selectedCheckbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/priorityView"
android:layout_alignTop="@id/priorityView"
android:layout_toRightOf="@id/priorityView"
android:gravity="center">
</CheckBox>
<TextView
android:id="@+id/dateText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/priorityView"
android:layout_toRightOf="@id/selectedCheckbox"
android:gravity="center"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="@string/empty"
android:textSize="20dip"
android:textStyle="bold" />
<TextView
android:id="@+id/monthText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/monthText"
android:layout_alignLeft="@id/dateText"
android:layout_alignRight="@id/dateText"
android:layout_below="@id/dateText"
android:gravity="center"
android:padding="5dip"
android:text="@string/empty"
android:textSize="10dip" >
</TextView>
<TextView
android:id="@+id/timeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/priorityView"
android:layout_alignTop="@id/priorityView"
android:layout_toRightOf="@id/dateText"
android:gravity="center"
android:padding="5dip"
android:text="@string/empty" >
</TextView>
<TextView
android:id="@+id/titleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/priorityView"
android:layout_alignParentRight="true"
android:layout_alignTop="@id/priorityView"
android:layout_toRightOf="@id/timeText"
android:gravity="center"
android:padding="5dip"
android:text="@string/empty" >
</TextView>
</RelativeLayout>
getView()
public View getView(int position, View convertView, ViewGroup parent) {
// List views that go off the screen are recycled.
View recycledView = convertView;
if (recycledView == null) {
/*
* If there is no view to recycle (e.g. when the listview is
* first created) we must inflate the view from the xml file
* using Layout Inflater.
*/
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
recycledView = inflater.inflate(R.layout.row, null);
}
/*
* We now have a view to work with. We will now fill in the contents
* of this list view item.
*/
Appointment current = items.get(position);
if (current != null) {
Log.e("crap",current.toString());
View priorityIndicator = (View) recycledView.findViewById(R.id.priorityView);
CheckBox selectedCheckbox = (CheckBox) recycledView.findViewById(R.id.selectedCheckbox);
TextView dateText = (TextView) recycledView.findViewById(R.id.dateText);
TextView monthText = (TextView) recycledView.findViewById(R.id.monthText);
TextView timeText = (TextView) recycledView.findViewById(R.id.timeText);
TextView titleText = (TextView) recycledView.findViewById(R.id.titleText);
//Set priority indictor to appropriate colour.
selectedCheckbox.setChecked(true);
switch (current.getPriority()) {
case PRIORITY_LOW:
priorityIndicator.setBackgroundColor(Color.BLUE);
break;
case PRIORITY_NORMAL:
priorityIndicator.setBackgroundColor(Color.GREEN);
break;
case PRIORITY_HIGH:
priorityIndicator.setBackgroundColor(Color.RED);
break;
default:
priorityIndicator.setBackgroundColor(Color.GRAY);
break;
}
//Leave the selected checkbox alone.
//Set dateText to show the date of the appointment
dateText.setText("29");
monthText.setText("SEP");
timeText.setText("11:00");
titleText.setText(current.getTitle());
}
return recycledView;
}
Try using Linear Layout with gravity attribute instead of relative layout. Relative layout is not ideal for inflating in a listview.