我需要在Frame Animated ImageView中检查当前帧,但我没有看到如何使用。我找不到获取当前帧的方法,我无法使用getImageResource()获取Imageview的当前图像,因为资源是停止动画的当前帧,而不是它自己的图像。
知道我能做些什么来找到当前帧是什么?
编辑: 解决方案最终意味着编写我自己的Frame动画代码:
要启动动画,请调用downDown();
要停止动画,请设置go = false;
布尔值'go',字符串'most_recent'和处理程序'mHandlerDown'全局声明。
mHandler = new Handler();
private void downDown(){
if(go ==true){
Runnable updateTask = new Runnable() {
public void run() {
ImageView lid = (ImageView)findViewById(R.id.lid); // the Imageview that will be animated
if (most_recent =="l1"){ //this loop checks the most recent frame updates with the next
lid.setImageResource(R.drawable.l2);
most_recent="l2";
} else if (most_recent =="l2"){
lid.setImageResource(R.drawable.l3);
most_recent="l3";
} else if (most_recent =="l3"){
lid.setImageResource(R.drawable.l4);
most_recent="l4";
} else if (most_recent =="l4"){
lid.setImageResource(R.drawable.l5);
most_recent="l5";
} else if (most_recent =="l5"){
lid.setImageResource(R.drawable.l6);
most_recent="l6";
} else if (most_recent =="l6"){
lid.setImageResource(R.drawable.l7);
most_recent="l7";
} else if (most_recent =="l7"){
lid.setImageResource(R.drawable.l8);
most_recent="l8";
} else if (most_recent =="l8"){
lid.setImageResource(R.drawable.l9);
most_recent="l9";
} else if (most_recent =="l9"){
lid.setImageResource(R.drawable.l10);
most_recent="l10";
} else if (most_recent =="l10"){
lid.setImageResource(R.drawable.l11);
most_recent="l11";
} else if (most_recent =="l11"){
lid.setImageResource(R.drawable.l12);
most_recent="l12";
}else if (most_recent == "l12"){
lid.setImageResource(R.drawable.l13);
most_recent="l13";
}
downDownCall();
}
};
mHandlerDown.removeCallbacks(updatetask);
mHandlerDown.postDelayed(updateTask, 40);
}
}
private void downDownCall(){
if(go== true){
downDown();
}
}