所以我想在这里使用ActivityOptionsCompat
ActivityOptionsCompat options =
ActivityOptionsCompat.makeSceneTransitionAnimation(NoticeViewer.class,
v, // The view which starts the transition
transitionName // The transitionName of the view we’re transitioning to
);
第一个参数应该是一个Activity对象,我试图通过相关的类文件提供,但是我得到以下类型转换错误 -
Error:(194, 54) error: no suitable method found for makeSceneTransitionAnimation(Class<NoticeViewer>,View,String)
method ActivityOptionsCompat.makeSceneTransitionAnimation(Activity,View,String) is not applicable
(actual argument Class<NoticeViewer> cannot be converted to Activity by method invocation conversion)
method ActivityOptionsCompat.makeSceneTransitionAnimation(Activity,Pair<View,String>...) is not applicable
(actual argument Class<NoticeViewer> cannot be converted to Activity by method invocation conversion)
我错过了一些非常简单的东西,但它是什么?
答案 0 :(得分:2)
使用NoticeViewer.this
代替NoticeViewer.class
将当前活动上下文作为第一个参数传递:
ActivityOptionsCompat.makeSceneTransitionAnimation(NoticeBoard.this,...)