android - Why doesn't ImageView load my image? -
i'm new android development forgive lack of knowledge on this. i'm trying make app finds image stored in internal memory , displays in imageview. i've gone through multiple ways image never displayed.
here's code far:
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tv = (textview)findviewbyid(r.id.textview); iv = (imageview)findviewbyid(r.id.frontimage); bv = (imageview)findviewbyid(r.id.backimage); bitmap mybitmap; file imgfile = new file(path,"front1.png"); //check if image exists if(imgfile.exists()) { //get image mybitmap = bitmapfactory.decodefile(imgfile.getabsolutepath()); iv.setimagebitmap(mybitmap); //add image imageview tv.settext(imgfile.getabsolutepath()); } }
i think textview tv displays correct path image doesn't load. can me this?
you need add read permission in manifest, other wise mybitmap null.
<uses-permission android:name="android.permission.read_external_storage" />
Comments
Post a Comment