I have activities with enter and exit transitions
Depends on actvity called to start, I have different shared elements
As you know I should use below method as secound parameter when calling startActivity():
ActivityOptions.makeSceneTransitionAnimation(Activity activity,
Pair<View, String>... sharedElements);
Because I use my different shared elements several times in code, I want to store my pairs in arrays to use for varags parameter.
By using this:
Pair<View, String>[] pairs = new Pair<View, String>[n];
I get "Generic array creation" error.
I have also tried using Arraylist like this:
ArrayList<Pair<View, String>> p = new ArrayList<>();
p.add(Pair.create(pauseButton, "sharedPauseBtn"));
p.add(Pair.create(toggleMusicButton, "sharedMusicBtn"));
Pair<View, String>[] pairs = p.toArray(new Pair<View, String>[n]);
And getting same "Generic array creation" error, I think Java doesn't allow it.
Any idea for storing some "Pair<View, String>" in an array as shared elements or another alternative solutions? I have searched all questions about array of generic class object in Java in stackoverflow but they doesn't help.