건방진프로그래머님이 알려주셔서
https://github.com/nostra13/Android-Universal-Image-Loader
여기에서 소스를 받아왔습니다
이소스 경로만 잘 고치면 sd카드의 이미지도 그대로 가져와서 할수가 있다고 해서요
그런데 전 어디를 고쳐야 될지 몰라서
일단 그리드뷰쪽의 소스만 고쳐봤습니다
더 고쳐야 될듯한데 잘 모르겠네요
ArrayList<ImgList> ImgList;
ImgList = new ArrayList<ImgList>();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/DCIM/Camera";
File mCurrentDirectory = new File(path);
for(File file : mCurrentDirectory.listFiles()){
if(file.getName().endsWith(".jpg")){
ImgList.add(new ImgList(path + "/" + file.getName()));
}
}
class ImgList{
String pImgPath;
public ImgList(String ImgPath){
pImgPath = ImgPath;
}
}
이렇게 해당 폴더의 파일 목록을 ImgList 에 넣고 그 데이터를 불러왔서
public View getView(int position, View convertView, ViewGroup parent) {
final ImageView imageView;
if (convertView == null) {
imageView = (ImageView) getLayoutInflater().inflate(R.layout.item_grid_image, parent, false);
} else {
imageView = (ImageView) convertView;
}
imageLoader.displayImage(ImgList.get(position).pImgPath, imageView, options);
return imageView;
}
getView 부분을 이렇게 줬습니다
그런데 전 이미지가 안불러와지네요
다른부분도 더 고쳐야될듯 한데
어떻게 고쳐야될지 몰라서요 ㅠ.ㅠ
앞에 file:// 붙이고 경로붙이세요.... 스키마 앞에붙여야 인식해요 웹은 http://인것처럼요..
음 이건 데모 읽어보시면 아실텐데... -_-