我使用AnimationDrawable創建由框架效應的框架,我想,當圖像變化,圓點一起換,我的代碼創建一個無限循環,如果我關閉While(mframeAnimation.isRunning())
然後它只檢查一次值並停止。
問:
所以,我應該怎麼做才能創造無限的檢查,收聽或類似的東西來改變圓圖像的變化是什麼時候?
private void selectDot(int arg2) {
// TODO Auto-generated method stub
for(int i=0;i<imageView.length;i++){
if(i==arg2) imageView[i].setImageResource(R.drawable.black_circle);
else imageView[i].setImageResource(R.drawable.gray_circle);
}
}
class Starter implements Runnable {
public void run() {
mframeAnimation.start();
while(mframeAnimation.isRunning()){
// Get the frame of the animation
Drawable currentFrame, checkFrame;
currentFrame = mframeAnimation.getCurrent();
int frameNumber;
// Checks the position of the frame
for (int i = 0; i < mframeAnimation.getNumberOfFrames(); i++) {
checkFrame = mframeAnimation.getFrame(i);
if (checkFrame == currentFrame) {
frameNumber = i;
// Toast.makeText(getActivity(), Integer.toString(frameNumber), Toast.LENGTH_SHORT).show();
selectDot(frameNumber);
break;
}
}
}
}
}
和你的問題是?通常它有助於指出你的期望和實際發生的事情 –
我認爲這很清楚,但我編輯了,謝謝 – Marckaraujo
@Marckaraujo我做了一個非常類似的廣告輪播也,我開始這樣做,因爲你正在做它,然後發現ViewFlipper使用起來更好,方式也更快,它通過提供的所有圖像構建在動畫製作器中,讓我知道如果您需要更多信息,我可以爲您提供一些代碼。 –