2013-06-11 3 views
0

나는 내 애플리케이션에서 OutOfMemory 오류을 직면하고있다. 이유는 내 애플리케이션에 많은 이미지가로드되어있다. 가능한 해결책을 찾다가이 링크를 발견하고 전체를 다운로드했다. 샘플 프로젝트 내 경우에 이미지를 온라인으로로드 것만 나는 내 문제와 관련이 찾을 http://developer.android.com/training/displaying-bitmaps/index.html비트 맵 드로어 드로어

, 내 응용 프로그램의 모든 이미지는 그래서

내 질문에 ... 드로어 블에서 찾을 수 있습니다 입니다, 내 drawabl에서 이미지를 사용할 수 있습니까? 특정 URL에서로드하지 말고 그것이 있다면, 친절하게 제게 그것의 아주 간단한 샘플을주세요. ...

나는 안드로이드 개발에 새로운 Im와 튜토리얼 온라인에 의존하는 Im 이후로 정말로 어려움을 겪고 있습니다. 감사합니다.

다음

내가

public class Images { 

/** 
* This are PicasaWeb URLs and could potentially change. Ideally the PicasaWeb API should be 
* used to fetch the URLs. 
* 
* Credit to Romain Guy for the photos: 
* http://www.curious-creature.org/ 
* https://plus.google.com/109538161516040592207/about 
* http://www.flickr.com/photos/romainguy 
*/ 
public final static String[] imageUrls = new String[] { 
     "https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg", 
     "https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg", 
     "https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg", 
     "https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg", 
     "https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg", 
     "https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s1024/Antelope%252520Walls.jpg", 
// more … 
     "https://lh4.googleusercontent.com/-e9NHZ5k5MSs/URqvMIBZjtI/AAAAAAAAAbs/1fV810rDNfQ/s1024/Yosemite%252520Tree.jpg", 
}; 

/** 
* This are PicasaWeb thumbnail URLs and could potentially change. Ideally the PicasaWeb API 
* should be used to fetch the URLs. 
* 
* Credit to Romain Guy for the photos: 
* http://www.curious-creature.org/ 
* https://plus.google.com/109538161516040592207/about 
* http://www.flickr.com/photos/romainguy 
*/ 
public final static String[] imageThumbUrls = new String[] { 
     "https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s160-c/A%252520Photographer.jpg", 
     "https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s160-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg", 
     "https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s160-c/Another%252520Rockaway%252520Sunset.jpg", 
     "https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s160-c/Antelope%252520Butte.jpg", 
     "https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s160-c/Antelope%252520Hallway.jpg", 
     "https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s160-c/Antelope%252520Walls.jpg", 
// … more 
     "https://lh4.googleusercontent.com/-e9NHZ5k5MSs/URqvMIBZjtI/AAAAAAAAAbs/1fV810rDNfQ/s160-c/Yosemite%252520Tree.jpg", 
}; 
} 

...에 대해 이야기하고 무엇 :이 코드는 내 설명이 충분히 명확하지 않은 경우 http://developer.android.com/training/displaying-bitmaps/index.html

임 죄송 주시기이 링크를 제공하는 샘플이었다 질문에 대한 후속 조치를 요청합니다 ... 감사합니다.

+0

인텐 트 메모리 크기가 몇 비트인지 알아야 대신 이미지를 처리하고 엄지 손가락을로드하십시오. –

답변

2

메모리에 이미지를 너무 많이 저장해서는 안됩니다. nostra으로 만든 훌륭한 라이브러리가 있습니다.

라이브러리 : https://github.com/nostra13/Android-Universal-Image-Loader

봅니다 라이브러리를 구현합니다. 이렇게하면 메모리로 인해 응용 프로그램이 강제 종료되지 않는 하드 캐싱을 제공합니다.

0

드로어 블 폴더에 너무 많은 이미지가있는 대신 필요한 경우 이미지를 다운로드하여 표시하는 것이 좋습니다.

btimaps를 효율적으로 표시해야합니다.

http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

은 또한 아래 링크

http://developer.android.com/training/displaying-bitmaps/manage-memory.html에서 관리 비트 맵 메모리를 확인 메모리에 규모 아래 버전을로드합니다. 당신이 메모리 누수가 발생하는 경우 URL에서 표시하는 이미지를 지연로드 기술을 사용하는 것을 고려하면

찾아 같은

https://www.youtube.com/watch?v=_CruQY55HOk

를 해결하기 위해 매트 분석기를 사용

What's LazyList?

Caching images and displaying

관련 문제