我知道这已经要求在这里,但我的问题是有点不同。我阅读了有关这个主题的其他答案,但他们没有解决我的问题。通行证的ImageView到下一个活动 - 安卓
所以在我的应用程序中,我有2个活动。在第一个中,有20个图像浏览(我打算增加更多),而在第二个活动中,有一个自定义视图,它实际上是一个缩放图像类。基本上,当用户在第一次活动时点击任何图像视图时,他将被带到第二个活动,在那里他可以放大该特定图像。
我理想中的编码部分做的是,让所显示的点击的ImageView的图像,并将其传递到下一个活动。为了达到这个目的,我使用了下面给出的代码,但它不起作用。什么可能是错的?
Activity_one
Intent startzoomactivity = new Intent(Activity_one.this, Activity_two.class);
Bitmap img_res = img.getDrawingCache();
Bundle extras = new Bundle();
extras.putParcelable("imagebitmap", img_res);
startzoomactivity.putExtras(extras);
startActivity(startzoomactivity);
Activity_two
Intent startzoomactivity = getIntent();
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");
TouchImageView img = new TouchImageView(this); // TouchImageView is the class that enables zoom feature on the imageview.
img.setImageResource(i);
img.setMaxZoom(5f);