gpt4 book ai didi

android - makeSceneTransitionAnimation 在使用 AndroidX 时显示错误

转载 作者:行者123 更新时间:2023-11-30 05:06:49 29 4
gpt4 key购买 nike

当我使用 android.support.v4

时,我有以下方法可以正常工作
override fun onClick(movie: Movie, poster: ImageView, name: TextView) {
val intent = Intent(activity, DetailActivity::class.java).apply {
putExtras(Bundle().apply {
putParcelable(EXTRA_MOVIE, movie)
})
}
val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
requireActivity(),

// Now we provide a list of Pair items which contain the view we can transitioning
// from, and the name of the view it is transitioning to, in the launched activity
Pair<View, String?>(poster, ViewCompat.getTransitionName(poster)),
Pair<View, String?>(name, ViewCompat.getTransitionName(name)))

// Now we can start the Activity, providing the activity options as a bundle
ActivityCompat.startActivity(requireContext(), intent, activityOptions.toBundle())
}

现在我想迁移到 androidx.core.app。出于某种原因,它在 makeSceneTransitionAnimation 上显示错误,指出 不能使用提供的参数调用以下函数

有人遇到过这样的问题吗?

enter image description here

最佳答案

对我来说,它是这样工作的:

//Watchout about this import, it is important!!
import androidx.core.util.Pair

//onCreate code avoided here
val testView = ImageView(this)

val activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
MainActivity.this,
Pair<View, String>(testView, "hi1"),
Pair<View, String>(testView, "hi2")
)
// ... startActivity code here

使用这两个依赖项:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'

关于android - makeSceneTransitionAnimation 在使用 AndroidX 时显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54425933/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com