2014-12-24 39 views
0

我想在onAnimationRepeat中執行一些操作。 其我的代碼:onAnimationRepeat中的代碼未運行

final LinearLayout l = (LinearLayout) findViewById(R.id.parent); 

//line 03 

     RotateAnimation anim = new RotateAnimation(0, 0, 0, 0); 
     anim.setInterpolator(new LinearInterpolator()); 
     anim.setRepeatCount(4); 
     anim.setDuration(10); 

     anim.setAnimationListener(new AnimationListener() { 

      @Override 
      public void onAnimationStart(Animation animation) { 

      } 

      @Override 
      public void onAnimationRepeat(Animation animation) { 
//line 01 
       View v = LayoutInflater.from(MainActivity.this).inflate(
         R.layout.product_layout, null); 
       TextView t = (TextView) v.findViewById(R.id.test); 
       t.setText(i + ""); 

       View root = v.findViewById(R.id.root); 
       View face = v.findViewById(R.id.face); 
       View back = v.findViewById(R.id.back); 

       l.addView(v); 
       flipCard(root, face, back); 
//line 02 
       i++; 
      } 

      @Override 
      public void onAnimationEnd(Animation animation) { 

      } 
     }); 
     l.startAnimation(anim); 

但它不工作。 當我將line 01-line 02代碼複製到line 03中時,它們都被執行(複製代碼和line 01-line 02代碼)。

什麼是問題? 謝謝

回答

0

我的問題解決了。

LinearLayout l

android:layout_height="wrap_content"

定義,它是空的。 我將它改爲

android:layout_height="match_parent"

我的問題解決了。