0

如何在第一个活动的第二个活动中设置图像?请我有一个严重的问题。帮我解决这个问题。

编辑(这已从评论中复制):

Intent put Extra的第一个活动代码:

in.putExtra("image", marraylist_image.get(arg2).toString()); 

在 imageview 中设置图像的第二个活动代码

image = mbundle.getString("image"); 
Bitmap bmp = BitmapFactory.decodeFile(image); 
System.out.println("Image Value:--" + bmp); 
img.setImageBitmap(bmp);
4

2 回答 2

0

活动1:

bytes[] imgs = ... // your image
Intent intent = new Intent(this, YourActivity.class);
intent.putExtra("img", imgs);
startActivity(intent);

活动2:

bytes[] receiver = getIntent().getExtra("img");

另请参阅答案。

于 2012-10-10T11:07:37.290 回答
0

Using bundle you can pass your image to seconfd activity like this :

               intent = new Intent(this, Second.class);
                bundle = new Bundle();
                bundle.putString("imageurl", "your image string");
                intent.putExtras(bundle);
                startActivity(intent);

and in second activity:

 bundle = new Bundle();
                   bundle = getIntent().getExtras();
                   imageurl_of_event = bundle.getString("imageurl");

and for displaying image:

HttpURLConnection conn;
                try {
                    URL feedImage = new URL(imageurl_of_event);
                    conn = (HttpURLConnection) feedImage.openConnection();
                    InputStream is = conn.getInputStream();
                    Bitmap img = BitmapFactory.decodeStream(is);
                    event_imageview.setImageBitmap(img);
}catch.....

thats it

于 2012-10-10T11:16:24.580 回答