怎么为两个imageview添加不同的图片?

Wang_xinze 发布于 2013/07/28 21:06
阅读 591
收藏 0

怎么设置点击button调用系统图库为两个imageview添加图片?我用下面的代码,但不管我怎么改,button2返回的图片都到imageview1上了,imageview2添加不进去。

 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
 
        if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };
 
            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColumn, null, null, null);
            cursor.moveToFirst();
 
            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String picturePath = cursor.getString(columnIndex);
            cursor.close();
 
            ImageView photo = (ImageView) findViewById(R.id.imageView1);
            photo.setImageBitmap(BitmapFactory.decodeFile(picturePath));
 
        }

 

加载中
0
斑马写代码
斑马写代码
楼上的问题解决了吗
0
pointerException
pointerException
  ImageView photo = (ImageView) findViewById(R.id.imageView1); 

  photo.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 

    看你这一句的目的就是设置imageView1的图片啊

返回顶部
顶部