我在我的android應用程序的可繪製文件夾中有170個圖像。我有一個活動顯示所有這些。想要做的是將點擊的圖像視圖傳遞給另一個活動(Zoom_activity),用戶可以在其中放大並使用它。我如何實現它?將ImageView從一個活動傳遞到另一個活動 - 意圖 - Android
所有的圖像都是500x500px。所以我想不出將它們解碼爲Bitmaps並通過Intent傳遞Btmaps。請建議一個更好和簡單的方法來做到這一點!我已經看過這裏的其他答案,但他們都沒有解決我的問題。
這裏是我的代碼:
Activity_1.java
Intent startzoomactivity = new Intent(Activity_one.this, Zoom_Image.class);
String img_name = name.getText().toString().toLowerCase(); //name is a textview which is in refrence to the imageview.
startzoomactivity.putExtra("getimage", img_name);
startActivity(startzoomactivity);
Zoom_Activity.java
Intent startzoomactivity = getIntent();
String img_res = getIntent().getStringExtra("getimage");
String img_fin = "R.drawable."+img_res;
img.setImageResource(Integer.parseInt(img_fin));
錯誤:應用強行關閉
請幫我解決這個問題!
謝謝!