Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected resource type of anim

.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."

like image 876
MrBoutte' Avatar asked Mar 08 '16 21:03

MrBoutte'


2 Answers

You are providing R.animator resources (@AnimatorRes) to the setCustomAnimations() method but it expects R.anim resource type (@AnimRes). If you switch to some animations which are referenced by R.anim it should compile and work.

but i'm not sure how I would use that in the middle of my method chaining as shown above

I'm not sure what you mean by this. Maybe this could shed some light on the matter. Also here you can find a list of all the Android annotations with short descriptions.

like image 54
JKMirko Avatar answered Sep 29 '22 20:09

JKMirko


You can use setCustomAnimations with Property Animation only with android.app.Fragment. And with android.support.v4.app.Fragment you should use TweenAnimation.

like image 26
Leonid Avatar answered Sep 29 '22 20:09

Leonid