简体   繁体   English

预期的动画资源类型

[英]Expected resource type of anim

.setCustomAnimations(R.animator.in_animation, R.animator.out_animation) the following throws "Expected respource type of anim" .setCustomAnimations(R.animator.in_animation,R.animator.out_animation)以下引发“预期的resimource类型的动画”

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? 我确实通过流程线程Android Studio的“预期的类型资源”检查检查了这个堆栈 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 我确实看到在这种情况下我可能会使用@Animator Res注释,但我不确定如何在我的方法链接中间使用它,如上所示

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." https://stackoverflow.com/a/18511350/5596604在这里,我看到了一个可能的解决方案,但不知道他在他的步骤中意味着什么,(将NineOldAndroids库导入support-v4库中导入了support-v4-nineoldandroids将库添加到我的项目中。)NineOldAndroids支持库的github链接,在配置部分“从类路径中删除Google的支持v4库”中说明。

You are providing R.animator resources ( @AnimatorRes ) to the setCustomAnimations() method but it expects R.anim resource type ( @AnimRes ). 您正在向R.animator setCustomAnimations()方法提供R.animator资源( @AnimatorRes ),但它需要R.anim资源类型( @AnimRes )。 If you switch to some animations which are referenced by R.anim it should compile and work. 如果你切换到R.anim引用的一些动画,它应该编译和工作。

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. 此外您还可以找到所有带有简短描述的Android注释的列表。

You can use setCustomAnimations with Property Animation only with android.app.Fragment. 您可以将setCustomAnimations与Property Animation一起使用,仅用于android.app.Fragment。 And with android.support.v4.app.Fragment you should use TweenAnimation . 使用android.support.v4.app.Fragment,你应该使用TweenAnimation

I'm pretty sure that you are using fragment of class android.support.v4.app.Fragment , but not android.app.Fragment . 我很确定你使用的是android.support.v4.app.Fragment类的片段,但不是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. 如果是这样,将您的片段更改为android.app.Fragment (相应地更改所有其他,例如getSupportFragmentManager()getFragmentManager() ),这应该有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM