samedi 16 mai 2015

Shared Elements Transition and GridViews

I can't seem to create a Shared Elements Transition from an Image in my main activity and an image in a detail activity.

The problem seems to be on the .makeSceneTransitionAnimation arguments. I have passed in a reference to the activity, an image and the shared transition name text which is labelled in both activitys resources. Android Studio says that this is an error and it looks as though it's something to do with the GridView Can anyone see what the issue is?

Please let me know if you need any other code examples?

CustomGrid adapter = new CustomGrid(ActorList.this, actorsNames, actorsImages);
        actorGrid = (GridView) findViewById(R.id.grid);
        actorGrid.setAdapter(adapter);

        final ImageView sharedImage = (ImageView) findViewById(R.id.grid_actor_image);

        actorGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {


            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    int position, long id) {

                Intent detailIntent = new Intent(getApplicationContext(), Detail.class);

                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, sharedImage, "profile");

                detailIntent.putExtra("name", actorObjectArrayList.get(position).getName());
                detailIntent.putExtra("description", actorObjectArrayList.get(position).getDescription());
                detailIntent.putExtra("dob", actorObjectArrayList.get(position).getDob());
                detailIntent.putExtra("country", actorObjectArrayList.get(position).getCountry());
                detailIntent.putExtra("spouse", actorObjectArrayList.get(position).getHeight());
                detailIntent.putExtra("children", actorObjectArrayList.get(position).getChildren());
                detailIntent.putExtra("image", actorObjectArrayList.get(position).getImage());
                startActivity(detailIntent, options.toBundle());
            }
        });

Aucun commentaire:

Enregistrer un commentaire