confirm that the ImageView picture is loaded successfully
This address: Http://blog.csdn.net/caroline_wendy
To determine if the ImageView picture exists and is not loaded successfully, the default picture is displayed.
if (mphotoview.getdrawable () = = null) {// Toast.maketext (getactivity (), "Picture loading Failed", Toast.length_short). Show (); Mphotoview.setimagedrawable (Getresources (). getdrawable (R.drawable.icon_default_user_photo)); }
conversion between bitmap, drawable, Byte,id in Android
1. Convert Bitmap to Byte
Bytearrayoutputstream out = new Bytearrayoutputstream (); Bitmap.compress (Bitmap.CompressFormat.PNG, +, out); byte[] Array= Out.tobytearray ();
2. Convert byte to bitmap
Bitmap Bitmap = bitmapfactory.decodebytearray (data, 0, data.length);
3. Bitmap converted to drawable
drawable drawable = new fastbitmapdrawable (bitmap);
4. drawable converted to bitmap
A. bitmapdrawable, fastbitmapdrawable directly with Getbitmap
B. Other types of drawable using canvas to draw on a bitmap
Canvas canvas = new Canvas (bitmap) Drawable.draw (canvas)
5.id Conversion graphic.drawable
drawable drawable = Activity.getresources (). getdrawable (R.drawable.icon);
6.id into bitmap
Bitmap Bitmap = bitmapfactory. Decoderesource (Resources res, int id)
Android-Confirm that the ImageView picture is loaded successfully