我似乎无法从主要活动中的图像和详细活动中的图像创建共享元素转换。
问题似乎出在.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());
}
});