Проверьте, что я сделал:
Кстати: CheckpointsView.getImageResId()
возвращает действительную ссылку для рисования
public class CheckpointCursorAdapter extends ResourceCursorAdapter {
private int layoutType = 0;
public static final int BLOTTER = 1;
public static final int DAY = 2;
public static final int MONTH = 3;
public static final int OVERVIEW = 4;
public static final int LAYOUT_ID = R.layout.checkpoint_row;
public CheckpointCursorAdapter(Context context, int layoutType, Cursor cursor) {
super(context, LAYOUT_ID, cursor);
this.layoutType = layoutType;
}
@Override
public View newView(Context context, Cursor cur, ViewGroup parent) {
LayoutInflater li = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return li.inflate(LAYOUT_ID, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView tvListText = (TextView) view.findViewById(R.id.txtCheckPoint);
Date dt = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseHelper.KEY_CHECKPOINT)));
switch (layoutType) {
case BLOTTER:
tvListText.setText(dt.toLocaleString());
((ImageView) view.findViewById(R.id.imgCheckpointInOut))
.setImageResource(CheckpointsView.getImageResId(cursor.getCount()
- cursor.getPosition()));
break;
case DAY:
tvListText.setText(new SimpleDateFormat("HH:mm:ss").format(dt));
((ImageView) view.findViewById(R.id.imgCheckpointInOut))
.setImageResource(CheckpointsView.getImageResId(cursor.getPosition() + 1));
break;
case MONTH:
tvListText.setText(new SimpleDateFormat("MMM dd HH:mm:ss").format(dt));
((ImageView) view.findViewById(R.id.imgCheckpointInOut))
.setImageResource(CheckpointsView.getImageResId(cursor.getPosition() + 1));
break;
case OVERVIEW:
break;
}
}
}
И XML на всякий случай
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/txtCheckPoint"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="20dp" android:padding="8dp" android:textStyle="bold">
</TextView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:gravity="right" android:layout_weight="1"
android:layout_marginRight="8px">
<TextView android:id="@+id/txtTotalHours"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="20dp" android:padding="8dp" android:paddingRight="12dp">
</TextView>
<TextView android:id="@+id/txtHourBalanceRow"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textSize="12dp" android:padding="8dp">
</TextView>
<ImageView android:id="@+id/imgCheckpointInOut"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:src="@drawable/black_clock" />
</LinearLayout>
Вы можете проверить весь код по адресу:
http://code.google.com/p/droidtimesheet/