我想显示从我的回收器视图到片段类的共享元素转换,我编写了以下代码:
holder.view.setOnClickListener {
val extras = FragmentNavigatorExtras(
holder.view.ivPersonImage to "imageView"
)
it.findNavController().navigate(
HomeFragmentDirections.actionNavHomeToTransactionFragment(
customerId,
customerName,
customerPhoneNumber,
imageString
), null, null, extras
)
}
它在 .navigate 处显示错误:
None of the following functions can be called with the arguments supplied:
private open fun navigate(@NonNull p0: NavDestination, @Nullable p1: Bundle?, @Nullable p2: NavOptions?, @Nullable p3: Navigator.Extras?): Unit defined in androidx.navigation.NavController
public open fun navigate(@IdRes p0: Int, @Nullable p1: Bundle?, @Nullable p2: NavOptions?, @Nullable p3: Navigator.Extras?): Unit defined in androidx.navigation.NavController
在片段类中,我正在使用:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
sharedElementEnterTransition = TransitionInflater.from(context).inflateTransition(android.R.transition.move)
}
似乎 safeArgs 不允许显示转换。我是 Android 新手,很难理解过渡和动画。请帮帮我,我在这里卡了这么多天了