2016-01-13 50 views
0

這段代碼應該做點擊按鈕時設置的動畫,等待動畫完成,然後加載新的活動。當我嘗試添加偵聽器時,出現Intent構造函數的錯誤。任何幫助都會很棒。帶意圖的動畫監聽器錯誤

public void onClick (View v) { 
     switch (v.getId()){ 
      case R.id.buttonStart: 
       wobble.setAnimationListener(new Animation.AnimationListener() { 
        @Override 
        public void onAnimationStart(Animation animation) { 
         buttonStart.startAnimation(wobble); 
        } 

        @Override 
        public void onAnimationEnd(Animation animation) { 
         startActivity(new Intent(this,CityRendActivity.class)); 
        } 

        @Override 
        public void onAnimationRepeat(Animation animation) { 

        } 
       }); 



       break; 
     } 
} 
} 
+0

以及有哪些誤區? – Leo

+0

而錯誤是? – M4ver1k

回答

1

它看起來像您傳遞在onAnimationEndthis是正在創建AnimationListener。你需要指定this您傳遞到Intent構造函數的活動:

@Override 
public void onAnimationEnd(Animation animation) { 
    startActivity(new Intent(MyActivity.this, CityRendActivity.class)); 
}