I've never worked with Fragments but I've had a similar issue with a scrollView once. I wanted to know when the scroll ended. Something you could probably do is implement your own listener. You could make a runnable (animationTask) and have that runnable check to see if some condition has been met to determine if the animation has ended and if not, keep calling the runnable.
In order to do this you'd need to make your own FragmentTransaction Class that extends FragmentTransaction and declare an interface (which will be your listener).
public abstract class M_FragmentTransaction extends FragmentTransaction {
private Runnable animationTask;
public interface OnAnimationFinish{
void onAnimationStopped();
}
private OnAnimationFinish onAnimationFinishListener;
public M_FragmentTransaction() {
super();
animationTask = new Runnable() {
public void run() {
while(!SOMETHING_TO_DETERMINE_IF_HAS_STOPPED){//has stopped
if(onAnimationFinishListener!=null){
onAnimationFinishListener.onAnimationStopped();
}
}
}
};
}
public void setOnAnimationFinish(OnAnimationFinish listener){
onAnimationFinishListener = listener;
}
public void startAnimationStart(){
animationTask.run();
}
Now in your posted code you'd put this you would have to look into converting the FragmentTransaction returned from getFragmentManager().beginTransaction(); into a M_FragmentTransaction since you can't do child = parent. I'm not too sure if this is more trouble than it's worth, but this approach helped me solve my problem.
Hope this helps!