android 如何读取SD卡某文件夹下所有图片并能滑动显示

android 如何读取SD卡某文件夹下所有图片并能滑动显示

1.先获取文件夹中的图片。
文件夹中的图片可参考此链接:http://blog.csdn.net/wei18359100306/article/details/40858723
2.用listView控件将图片显示,listView可以滑动显示
可参考此连接:http://www.cnblogs.com/allin/archive/2010/05/11/1732200.html

刚弄完你这样的需求,String path;
if(isPhoto) {
path = Util.local_photo_path;
} else {
path = Util.local_movie_path;
}

    File folder = new File(path);
    File [] files = folder.listFiles();
    FileInputStream fis = null;

    String[] list = folder.list();



    ArrayList<ListItem> listMockData = new ArrayList<ListItem>();这是获取数据的集合,

    imageView.setOnTouchListener(new GestureListener(this) {
            @Override  
            public boolean left() {                 
                if(position <list.length-1) {     
                    Log.e("向左滑", position+"");
                    position = position + 1;
                    /* myBitmap = BitmapFactory.decodeFile(folder.toString() + "/" + list[position]);
                    imageView.setImageBitmap(myBitmap);*/


                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inJustDecodeBounds = true;
                    String fullFilePathString = folder.toString() + "/" + list[position];
                    WindowManager windowManager = getWindowManager();
                    Display winDisplay = windowManager.getDefaultDisplay();
                    int width = winDisplay.getWidth();
                    int scale = 1;
                    if (options.outWidth>width) {
                        scale = options.outWidth/width;

                    }
                    options.inJustDecodeBounds = false;
                    options.inSampleSize = 3;
                    Bitmap myBitmap = BitmapFactory.decodeFile(fullFilePathString,options);
                    imageView.setImageBitmap(myBitmap);
                } else {

                    mToastComon.ToastShow(GalleryActivity.this, Toast.LENGTH_SHORT,  "已经是最后一张了!");
                }           
                return super.left();  
            }
            @Override  
            public boolean right() {  
                if(position > 0) {
                    Log.e("向右滑", position+"");
                    position = position - 1;
                    /*Bitmap myBitmap = BitmapFactory.decodeFile(folder.toString() + "/" + list[position]);
                    imageView.setImageBitmap(myBitmap);*/


                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inJustDecodeBounds = true;
                    String fullFilePathString = folder.toString() + "/" + list[position];
                    WindowManager windowManager = getWindowManager();
                    Display winDisplay = windowManager.getDefaultDisplay();
                    int width = winDisplay.getWidth();
                    int scale = 3;
                    if (options.outWidth>width) {
                        scale = options.outWidth/width;

                    }
                    options.inJustDecodeBounds = false;
                    options.inSampleSize = scale;
                    Bitmap myBitmap = BitmapFactory.decodeFile(fullFilePathString,options);
                    imageView.setImageBitmap(myBitmap);
                } else {
                    mToastComon.ToastShow(GalleryActivity.this, Toast.LENGTH_SHORT,  "已经是第一张了!");
                } 
                return super.right();  
            }  
        });
    }  

    这是滑动的手势,要源码可以私聊