Andrei P Andrei P - 4 months ago 22
Android Question

Replace in FragmentTransiction cannot be applied to InfoFragment

I want to set custom animations for a transaction between two fragments, but it says that replace in the fragment transaction cannot be applied to InfoFragment(a fragment which extends Fragment), just to android.app.fragment.

infoFragment=InfoFragment.newInstance(latitude,longitude);
getFragmentManager()
.beginTransaction()
.setCustomAnimations(R.animator.card_flip_right_in,R.animator.card_flip_right_out,R.animator.card_flip_left_in,R.animator.card_flip_left_out)
.replace(R.id.fragment_container,infoFragment)
.addToBackStack(null)
.commit();


enter image description here

Answer

Since you're saying your InfoFragment is extending Fragment, the only thing that may be causing the issue is the fragment packages. Make sure your InfoFragment is importing android.app.Fragment only and not from the Support package.