Expected resource type of anim

Viewed 5944

.setCustomAnimations(R.animator.in_animation, R.animator.out_animation) the following throws "Expected respource type of anim"

getSupportFragmentManager()
            .beginTransaction()
            .setCustomAnimations(R.animator.in_animation, R.animator.out_animation)
            .replace(R.id.a_fragment, SingleAnswerFragment.newInstance())
            .addToBackStack(null)
            .commit();

I did check this stack over flow thread Android Studio's "expected resource of type" checks? and I did see where in this case I might use @Animator Res annotation, but i'm not sure how I would use that in the middle of my method chaining as shown above

https://stackoverflow.com/a/18511350/5596604 Here I see a possible solution but have no idea what he means in his steps where he, (Imported the NineOldAndroids library into the support-v4 Library Imported the support-v4-nineoldandroids library into my project.) The github link for that support library for NineOldAndroids, states in the configuration part " remove Google's support v4 library from your classpath."

3 Answers

I'm pretty sure that you are using fragment of class android.support.v4.app.Fragment, but not android.app.Fragment. This class is not allowing property animation that you try to use. If so, change your fragment to android.app.Fragment (change all other accordingly, for example getSupportFragmentManager() to getFragmentManager()), this should help.

Related