2016-02-27 54 views

回答

0
ImageRequest imgRequest = new ImageRequest(url, new Response.Listener<Bitmap>() { 
    @Override 
    public void onResponse(Bitmap _bitmapScaled) { 

     ByteArrayOutputStream bytes = new ByteArrayOutputStream(); 
     _bitmapScaled.compress(Bitmap.CompressFormat.JPEG, 40, bytes); 

     //you can create a new file name "test.jpg" in sdcard folder. 
     File f = new File(Environment.getExternalStorageDirectory() 
           + File.separator + "test.jpg") 
     f.createNewFile(); 
     //write the bytes in file 
     FileOutputStream fo = new FileOutputStream(f); 
     fo.write(bytes.toByteArray()); 

     // remember close de FileOutput 
     fo.close(); 


    } 
    }, 0, 0, ImageView.ScaleType.CENTER_CROP, Bitmap.Config.ARGB_8888, 
    new Response.ErrorListener() { 
    @Override 
    public void onErrorResponse(VolleyError error) { 
     //do stuff 
    } 
}); 
+0

謝謝!很多!我會嘗試一下。 –

+0

當然..如果這能幫助你,請批准答案。 –

+0

我在其他帖子上找到了答案(最後):) http://stackoverflow.com/a/24650151/5487135 –