我有一个最初设置为可绘制资源的 ImageButton。在活动期间,我想将图像设置为用户照片的位图。拍照和保存工作正常,但 ImageButton 的图像没有改变。
这是我的代码:
Bitmap bitmap = BitmapFactory.decodeFile(PATH + "/image.jpg");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 20, stream);
Log.d(TAG, bitmap.toString()); //prints out android.graphics.Bitmap@41d772a8
rearEndImageButton.setImageBitmap(bitmap);