Вот остальная часть кода, используя SDImageLoader, связанный с вышеупомянутым отсюда: http://www.samcoles.co.uk/mobile/android-asynchronously-load-image-from-sd-card
Класс ListAdapter:
public class PBListAdapter extends SimpleCursorAdapter {
//MEMBERS:
private int mLayoutId;
private SpecimenHunterDatabaseAdapter mDbHelper;
private final SDImageLoader mImageLoader = new SDImageLoader();
//METHODS:
public PBListAdapter(Context context, int layout, Cursor c) {
super(context, layout, c, new String[] {}, new int[] {});
mLayoutId = layout;
mDbHelper = new SpecimenHunterDatabaseAdapter(context);
mDbHelper.open();
}
@Override
public View newView(Context context, Cursor c, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(mLayoutId, parent, false);
return v;
}
@Override
public void bindView(View v, Context context, Cursor c) {
String title = c.getString(c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_TITLE));
String species = mDbHelper.fetchSpeciesName(c.getInt(c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_SPECIES)));
int pounds = c.getInt((c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_POUNDS)));
int ounces = c.getInt((c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_OUNCES)));
int drams = c.getInt((c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_DRAMS)));
String weight = pounds + context.getString(R.string.addcapture_pounds) + " " +
ounces + context.getString(R.string.addcapture_ounces) + " " +
drams + context.getString(R.string.addcapture_drams);
String photoFilePath = c.getString(c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_PHOTO));
String comment = c.getString(c.getColumnIndexOrThrow(SpecimenHunterDatabaseAdapter.KEY_CAPTURES_COMMENT));
TextView nameView = (TextView)v.findViewById(R.id.pb_row_species_name);
TextView weightView = (TextView)v.findViewById(R.id.pb_row_capture_weight);
TextView titleView = (TextView)v.findViewById(R.id.pb_row_capture_title);
TextView commentView = (TextView)v.findViewById(R.id.pb_row_capture_comment);
ImageView photoView = (ImageView)v.findViewById(R.id.pb_row_capture_photo);
mImageLoader.load(context, photoFilePath, photoView);
nameView.setText(species);
titleView.setText(title);
weightView.setText(weight);
commentView.setText(comment);
}
}
В фактической ListActivity, в вашем onCreate () установите адаптер списка:
private void bindData() {
Cursor c = mDbHelper.fetchAllPBs();
startManagingCursor(c);
setListAdapter(new PBListAdapter(this, R.layout.pb_list_item, c));
}
В моем примере абсолютные пути к файлам изображений сохраняются в базе данных при добавлении через приложение.