I add a fragment with an animated transition. The transition takes about 1 second.

fragmenttransaction = fragmentmanager.beginTransaction(); fragmenttransaction.setCustomAnimations(R.anim.alpha_start, R.anim.alpha_end); fragmenttransaction.replace(R.id.container, fragmentArrayList.get(indexSlide)); fragmenttransaction.commit(); 

There is a button that switches fragments like a slider. If I often press a button while the animation transition is on, then an error occurs.

I want to do the following, when I press the button, it becomes inactive as soon as the animation transition is over, the button can be pressed again. I did not find a method where I can hang the callback function to complete the commit.

On the Internet did not find. There is only how to track inside the fragment itself that the animation of the appearance of the fragment is complete. It does not suit me.

  • You can block the button for a time = animation duration - andreich
  • This is not entirely correct. Is there no method that works as soon as the commit is complete? - inkognitum

0