저는 많은 응용 프로그램에서 animationdrawable을 사용하고 있습니다.AnimationDrawable에서 사용 가능한 메모리가 없습니다.
그런 다음public void prepareVideo (int resourceBall, String animation, int width, int height){
imgBall = (ImageView)findViewById(resourceBall);
imgBall.setVisibility(ImageView.VISIBLE);
String resourceNameAnimation = animation;
int id_res = getResources().getIdentifier(resourceNameAnimation, "drawable", getPackageName());
imgBall.setBackgroundResource(id_res);
LayoutParams latoutFrame = imgBall.getLayoutParams();
latoutFrame.width = width;
latoutFrame.height = height;
imgBall.setLayoutParams(latoutFrame);
frame = (AnimationDrawable) imgBall.getBackground();
}
내가 전화 : :이 그들을 inicializate하는 코드입니다 imgBall.post를 (새 StartAnimation());
실행 가능한 전화:
class StartAnimation implements Runnable {
public void run() {
frame.start();
}
}
문제는 난이 같은 XML (프레임마다)를 사용하는 많은 애니메이션을 사용하는 것이다. 같은 애니메이션으로 많은 액티비티에서이 메서드를 호출해야합니다. 마침내 나는 outofmemoryerror를 얻는다. 나는 화면 사이에 메모리를하려고 해요 : "재활용 비트 맵을 사용하려고 시도하는 것은"
사람은 다른 방법을 알고 :
for (int i = 0; i < frame.getNumberOfFrames(); ++i){
Drawable frame_rescue = frame.getFrame(i);
if (frame_rescue instanceof BitmapDrawable) {
((BitmapDrawable)frame_rescue).getBitmap().recycle();
}
frame_rescue.setCallback(null);
문제는 내가 다시 resourde를 사용하려고하면 y는 다른 오류를 얻을 수 있다는 것입니다 무료 메모리의?