【问题标题】:Shared Elements Transition and GridViews共享元素转换和 GridView
【发布时间】:2015-05-13 12:55:15
【问题描述】:

我似乎无法从主要活动中的图像和详细活动中的图像创建共享元素转换。

问题似乎出在.makeSceneTransitionAnimation 参数上。我已经传递了对活动的引用、图像和在两个活动资源中标记的共享转换名称文本。 Android Studio 说这是一个错误,看起来好像与 GridView 有关系 谁能看出问题所在?

如果您需要任何其他代码示例,请告诉我?

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());
            }
        });

【问题讨论】:

    标签: android android-intent android-animation android-transitions


    【解决方案1】:

    您正在传递this,它是对当前对象的引用,即 OnItemClickListener。因为你在一个内部类中,所以你实际需要传递的是YourActivityName.thisActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(YourActivityName.this, sharedImage, "profile");

    【讨论】:

      猜你喜欢
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多