错误 resolveUri failed on bad bitmap uri: android.graphics.drawable.BitmapDrawable@485d7dd0

<span style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;">直接用SimpleAdapter更新一开始获取的Drawable类型的Icon的图像时,会出现错误:</span><br style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;" /><span style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;">I/System.out(284): resolveUri failed on bad bitmap uri: android.graphics.drawable.BitmapDrawable@485d7dd0</span><br style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;" /><br style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;" /><span style="color: rgb(145, 166, 147); font-family: 宋体; font-size: 14px; line-height: 22px;">解决方法 可以使用SimpleAdapter的ViewBinder方法来实现对Drawable或者Image类型图片的更新</span>
		SimpleAdapter simpleAdapter = new SimpleAdapter(this, items,
				R.layout.griditeminfo, new String[] { "appImage", "appName", },
				new int[] { R.id.itemimage, R.id.itemtext }) {
		};
		simpleAdapter.setViewBinder(new ViewBinder(){
	           public boolean setViewValue(View view,Object data,String textRepresentation){
	                 if(view instanceof ImageView && data instanceof Drawable){
	                 ImageView iv=(ImageView)view;
	                      iv.setImageDrawable((Drawable)data);
	                                return true;
	                           }
	                              else return false;
	                           }
	                      });
		gridView.setAdapter(simpleAdapter);

	}

我做了一个安卓画板app现在添加了一个从url下载图片并设置成画板背板的功能。我把代码给你看,在我输入了https://www.nottingham.edu.cn/image-library/campus-news/signofnottingham.jpg的网站后提示下载失败 /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cn.edu.nottingham.jianxingwang.fingerpainter; import android.content.ContentResolver; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Path; import android.net.Uri; import android.os.Bundle; import android.os.Parcelable; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.view.View; import android.widget.Button; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Stack; /** * Created by pszmdf on 13/10/16. * * Derived from android graphics API sample com.example.android.apis.graphics.Fingerpaint * android.googlesource.com/platform/development/+/master/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.java * */ public class FingerPainterView extends View { private Context context; private Canvas canvas; private Paint paint; private Bitmap bitmap; private Path path; private Uri uri; private Stack<Bitmap> undoStack = new
最新发布
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值