Search code examples
javaandroidimage-galleryimagelist

displaying images Gallery from assets/images


i would like to Display an image gallery but from "assets/images" folder not from the phone storage.

like this one: enter image description here


Solution

  • The question is not clear, if you want to load a single image from assets, then you can do it this way.

    //read image from asset
    InputStream is = getAssets().open("image.jpg");
    
    //    create a drawable
    Drawable drawable = Drawable.createFromStream(is, null);
    
    //find reference to your imageview and set drawable
    ImageView i=(ImageView)findViewById(R.id.image_id); 
    i.setImageDrawable(drawable);