Load an image from assets folder into an ImageView in Android
For testing purpose, this code snippet can be run in the onCreate Method of an Activity class. It renders an image in app/assets/my_image.jpg into an ImageView.
AssetManager assetManager = getAssets(); ImageView imageView = (ImageView) findViewById(R.id.iv_image); try { InputStream ims = assetManager.open("my_image.jpg"); Drawable d = Drawable.createFromStream(ims, null); imageView.setImageDrawable(d); } catch (IOException ex) { return; }
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts