使用以下代码Intent跳转到系统的自带图片浏览器,但怎么获取选中的图片数据显示到一个ImageView上?请大家帮忙解答。Intent intent = new Intent();  
                /* 开启Pictures画面Type设定为image */  
                intent.setType("image/*");  
                /* 使用Intent.ACTION_GET_CONTENT这个Action */  
                intent.setAction(Intent.ACTION_GET_CONTENT);             
                /* 取得相片后返回本画面 */  
                startActivityForResult(intent,1);  

解决方案 »

  1.   

    重写onActivityResult函数,你选中的图片后,会返回数据存在data里面,之后需要什么就操作这个data就ok了。
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == 1 && resultCode == RESULT_OK){
    Log.i("onActivityResult", "在此获得");
    Uri uri = data.getData();
    ContentResolver re = getContentResolver();
    Bitmap bitmap;
    try {
    bitmap = MediaStore.Images.Media.getBitmap(re, uri);
    //显示
    imv01.setImageBitmap(bitmap);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }