我使用以下代码:
Bitmap bMap = BitmapFactory.decodeFile(firstPageAddress);
mImageView.setImageBitmap(bMap);
我也试过使用这段代码:
mImageView.setImageDrawable(Drawable.createFromPath(firstPageAddress));
firstPageAddress - 设备外部存储器中jpg文件的路径。
两种情况下的结果都是一样的: my imageview drawable after setImage in debugger (按ViewBitmap后,我看到正确的图像)
在升级库版本之前,一切正常。
我用过:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
现在我正在使用:
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:support-v4:25.3.0'
compile 'com.android.support:design:25.3.0'
任何想法?谢谢 !
答案 0 :(得分:0)
试试这个:
new AsyncTask<Bitmap, Bitmap, Bitmap>() {
@Override
protected Bitmap doInBackground(Bitmap... params) {
try {
URL url = new URL("https://static.pexels.com/photos/3247/nature-forest-industry-rails.jpg");
Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
return image;
} catch(IOException e) {
System.out.println(e);
}
return null;
}
@Override
protected void onPostExecute(Bitmap bitmap) {
super.onPostExecute(bitmap);
}
}.execute();