3

我有一个包含 2 个片段的活动。我使用setCustomAnimations函数为片段事务添加了自定义动画。现在我想在片段过渡动画效果之后执行一些操作。为此,我在主 Activity 中实现了android.view.animation.Animation.AnimationListener接口。但是在片段转换操作之后不会调用onAnimationEnd方法。请帮忙!!

4

2 回答 2

1

您不能在这些动画上设置 AnimationListener,因为它们是使用资源标识符提供的。要设置 AnimationListener,您需要在代码中引用动画,并且能够调用 setAnimationListener 以在给定动画上实际设置 AnimationListener。

于 2012-04-04T14:44:11.250 回答
1

您需要使用以下方法之一在代码中设置动画(取决于您是否使用兼容性库):

http://developer.android.com/reference/android/app/Fragment.html#onCreateAnimator(int , boolean, int)

http://developer.android.com/reference/android/support/v4/app/Fragment.html#onCreateAnimation(int , boolean, int)

于 2012-10-22T06:05:31.277 回答