Varargs Kotlin Java interop not working properly
This worked for me:
import android.support.v4.util.Pair
// ...
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity,
Pair<View, String>(image, image.transitionName),
Pair<View, String>(title, title.transitionName))
startActivity(intent, options.toBundle())
It may be the case that you're accidentally using kotlin.Pair
instead of android.util.Pair
. Please add the following import directive to the beginning of your file:
import android.util.Pair
The answer is the *
symbol before array variable:
import android.support.v4.util.Pair as AndroidPair
// ...
val pair1 = AndroidPair<View, String>(fab,
getString(R.string.transition_fab))
val pair2 = AndroidPair<View, String>(findViewById(R.id.app_bar),
getString(R.string.transition_appbar))
ActivityOptionsCompat.makeSceneTransitionAnimation(this@MyActivity,
*arrayOf(pair1, pair2)).toBundle();