1
淡出後,我有這樣的代碼來創建動畫淡入與圖像顯示進度條動畫
push_top_in代碼創建一個褪色從上到下動畫
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="1000"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
</set>
JAVA代碼調用push_top_in動畫
ImageView imvLogo = (ImageView) findViewById(R.id.imvLogo);
Animation myFadeInAnimation = AnimationUtils.loadAnimation(MisCompras.this, R.animator.push_top_in);
imvLogo.startAnimation(myFadeInAnimation);
現在我想顯示一個進度條,當動畫結束,我用這個代碼
myFadeInAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
progressBarCust = (ProgressBar)findViewById(R.id.progressBar);
textViewLoad = (TextView)findViewById(R.id.txvProgreso);
Handler hdl = new Handler();
hdl.postDelayed(new MiSuperHandler(), 5000);
}
});
但setAnimationListener代碼拋出一個異常
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{miscompras.principal/miscompras.principal.MyActivity}: java.lang.NullPointerException
,我不知道什麼是錯
請幫助
感謝您的幫助 – japuentem
不客氣。如果它有用,請接受答案。 –