Help with Gallery App

Search This thread

SimplicityApks

Senior Member
May 26, 2013
354
344
Aachen
I have found a gallery app that I have integrated into my own app.
http://manishkpr.webheavens.com/android-viewpager-as-image-slide-gallery-swipe-gallery/
Currently the gallery displays images that are founded in drawable i want to modify it to show image from sd card (i.e. /sd/images/)
I tried different approach but without luck, unfortunately.

Thanks in advance!

You have to use BitmapFactory.decodeFile() on each File in that directory. You can then set the returned bitmap to your imageView in the instantiateItem() method of your PagerAdapter with setImageBitmap(). Though you might want to cache thing first for better performance...
 
  • Like
Reactions: heahmad

heahmad

Senior Member
Dec 2, 2009
128
35
ok i know that, but the problem is that the app itself generate photos with different number and name (Timestamp) so i want it to read an entire folder not a single file each time
 

zipzip27

Member
Feb 8, 2012
21
16
29
Ho Chi Minh
ok i know that, but the problem is that the app itself generate photos with different number and name (Timestamp) so i want it to read an entire folder not a single file each time
you can get all images from diretory

PHP:
File file= new File(android.os.Environment.getExternalStorageDirectory(),"MyFolder");

        if (file.isDirectory())
        {
            listFile = file.listFiles();


            for (int i = 0; i < listFile.length; i++)
            {

                f.add(listFile[i].getAbsolutePath());

            }
        }
 
  • Like
Reactions: heahmad

heahmad

Senior Member
Dec 2, 2009
128
35
you can get all images from diretory

PHP:
File file= new File(android.os.Environment.getExternalStorageDirectory(),"MyFolder");

        if (file.isDirectory())
        {
            listFile = file.listFiles();


            for (int i = 0; i < listFile.length; i++)
            {

                f.add(listFile[i].getAbsolutePath());

            }
        }

i do not get it can you explain more, there is no return function with data
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    I have found a gallery app that I have integrated into my own app.
    http://manishkpr.webheavens.com/android-viewpager-as-image-slide-gallery-swipe-gallery/
    Currently the gallery displays images that are founded in drawable i want to modify it to show image from sd card (i.e. /sd/images/)
    I tried different approach but without luck, unfortunately.

    Thanks in advance!

    You have to use BitmapFactory.decodeFile() on each File in that directory. You can then set the returned bitmap to your imageView in the instantiateItem() method of your PagerAdapter with setImageBitmap(). Though you might want to cache thing first for better performance...
    1
    ok i know that, but the problem is that the app itself generate photos with different number and name (Timestamp) so i want it to read an entire folder not a single file each time
    you can get all images from diretory

    PHP:
    File file= new File(android.os.Environment.getExternalStorageDirectory(),"MyFolder");
    
            if (file.isDirectory())
            {
                listFile = file.listFiles();
    
    
                for (int i = 0; i < listFile.length; i++)
                {
    
                    f.add(listFile[i].getAbsolutePath());
    
                }
            }