//viewGroup表示的是main.xml中的整個布局
//將imageView添加到布局中
viewGroup.addView(addImageView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
//alphaAnimation.setAnimationListener(new addAnimationListener());
imageView = addImageView;
addImageView.startAnimation(alphaAnimation);
}
}
//AnimationLinstener主要是在Animation動畫效果的開始和結束等周期時,會調用其中的相關函數
class RemoveAnimationListener implements AnimationListener{
//當Animation效果結束後調用此方法
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
System.out.println("Animation end");
//將ImageView在布局中刪除
viewGroup.removeView(imageView);
}
//當animation效果重復執行時調用此方法
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
System.out.println("Animation repeat");
}
//當animation效果開始執行時調用此方法
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
System.out.println("Animation start");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}