我为我的应用程序准备了可绘制动画的no.All工作正常。当应用程序启动可绘制动画将开始,我在同一活动中有两个按钮(下一个和上一个)。当我点击下一个或上一个按钮动画将会改变。它工作正常。但是当我点击下一个或上一个按钮时,需要时间来更改动画。这是我的代码,
mImgLetter.clearAnimation();
Log.d("before clear","------");
mImgLetter.setBackgroundResource(resID);
Log.d("after clear","------");
mImgLetter.post(new Runnable() {
public void run() {
loadingAnimation = (AnimationDrawable) mImgLetter
.getBackground();
loadingAnimation.start();
}
});
当我点击按钮时,如何减少两个可绘制动画的开始时间。请帮助我。
Logcat是,
02-21 17:52:57.278: D/before clear(813): ------
02-21 17:52:57.337: D/dalvikvm(813): GC freed 285 objects / 12160 bytes in 47ms
02-21 17:52:57.568: D/dalvikvm(813): GC freed 255 objects / 13568 bytes in 50ms
02-21 17:52:57.798: D/dalvikvm(813): GC freed 24 objects / 1016 bytes in 49ms
02-21 17:52:58.018: D/dalvikvm(813): GC freed 24 objects / 1016 bytes in 48ms
02-21 17:52:58.808: D/dalvikvm(813): GC freed 24 objects / 1024 bytes in 52ms
02-21 17:52:59.447: D/dalvikvm(813): GC freed 24 objects / 1016 bytes in 327ms
02-21 17:53:00.127: D/dalvikvm(813): GC freed 26 objects / 1160 bytes in 51ms
02-21 17:53:00.358: D/dalvikvm(813): GC freed 24 objects / 1032 bytes in 49ms
02-21 17:53:01.138: D/dalvikvm(813): GC freed 26 objects / 1552 bytes in 48ms
02-21 17:53:01.678: D/after clear(813): ------
GC将花费大量时间。让我知道如何减少GC时间。