Thumbnail bitmap image doesn't show up in fragment class -
the dilemma want use mediastore.images.thumbnails.getthumbnail thumbnail sdcard , show in fragment class (which requested in mainactivity). here code. there no error in code imageview shows nothing @ all.
public class fragmentclass extends fragment { string tag = "hi"; imageview image; long imageid; public fragmentclass() {} @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.fragment_fragment_class, container, false); image = (imageview) v.findviewbyid(r.id.imageview); string projection[] = { mediastore.images.thumbnails._id, mediastore.images.thumbnails.data}; contentresolver contentresolver = getactivity (). getcontentresolver(); cursor cursor = mediastore.images.thumbnails.query(contentresolver, mediastore.images.thumbnails.external_content_uri, projection); cursor.movetofirst(); imageid = cursor.getint(cursor.getcolumnindex(mediastore.images.thumbnails._id)); cursor.close(); final bitmapfactory.options bmoptions = new bitmapfactory.options(); bmoptions.insamplesize =2; bitmap bitmap = mediastore.images.thumbnails.getthumbnail( contentresolver, imageid, mediastore.images.thumbnails.micro_kind, bmoptions); //image.setimagebitmap(bitmap); image.setimagebitmap(bitmap); // inflate layout fragment return v; }
}
why not using recent-images library? makes thumbnails of device photos , set them in gridview, can custom purpose.
Comments
Post a Comment