android - populating a listView with images on the device -
android - populating a listView with images on the device -
ok ive spent lastly 2 days looking simple illustration of how utilize images on device populate list view , ive come conclusion there no easy way this. know everytime set bits , pieces 1 elses examples end lots of code dont need. can 1 please show me how load images device list view. there no book, tutorial, or post on here shows how , kind of funny , crazy @ same time.
here's rest of code, using sdimageloader linked above here: http://www.samcoles.co.uk/mobile/android-asynchronously-load-image-from-sd-card
the listadapter class:
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); homecoming 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); } } in actual listactivity, in oncreate() set list adapter:
private void binddata() { cursor c = mdbhelper.fetchallpbs(); startmanagingcursor(c); setlistadapter(new pblistadapter(this, r.layout.pb_list_item, c)); } in illustration absolute filepaths images stored in database when added via app.
android listview android-layout android-sdcard
Comments
Post a Comment