android之传递图片
//将主的页面中要传递的内容封装到intent(意图中去)
public void onClick(View v)
{
Intent intent = new Intent(MainActivity.this,SecondActivity.class);
Bundle bundle = new Bundle();
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drwable.lamp);
bundle.putPracelable("bitmap",bitmap);
intent.putExtras(bundle);
startActivity(intent);
}
protected void onCreate(Bundle saveInstaceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
ImageView =(ImageView)findViewById(R.id.imageView);
Intent intent = getIntent();
if(intent!=null)
{
Bitmap bitmap = intent.getPracelableExtra("bitmap");
image.setImageBitmap(bitmap);
}
}
于是乎就实现将图片进行传递
注意在使用bundle传送数据时,不要用bundle传送大量的数据