从一个活动图像发送到另一 [英] send image from one activity to another
本文介绍了从一个活动图像发送到另一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从一个活动发送图像到另一个,但我不知道如何设置ImageView的。
I am trying to send an image from one activity to another but I dont know how to set the imageview.
下面是我如何将图像和其他的东西
here is how I send the image and other stuff
Intent item_intent = new Intent(MainActivity.this, Item.class);
item_intent.putExtra("name","test name arif");
item_intent.putExtra("quantity","99");
//*************************here is the image***************************
item_intent.putExtra("image",R.drawable.access);
MainActivity.this.startActivity(item_intent);
下面是我如何想读取图像,并将其设置为ImageView的,但我得到一个语法错误。
here is how I am trying to read the image and set it to the ImageView but I am getting a syntax error.
Intent intent = getIntent();
ImageView img_view = (ImageView) findViewById(R.id.item_image);
// this where I am having problem below******************************
img_view.setImageBitmap(intent.getByteArrayExtra("image"));
我应该如何设置ImageView的?
how should I set the ImageView?
推荐答案
你不觉得
img_view.setImageBitmap(intent.getByteArrayExtra("quantity"));
应
img_view.setImageResource(intent.getIntExtra("name",R.drawable.default_image));
这篇关于从一个活动图像发送到另一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文