我想将存储在数据库中的图像地址设置为图像视图
我有这段代码,但我不知道这样做,我将名称列添加到TextView但我无法将图像地址设置为imageview
请帮助我!
源代码:
@Override
public View getView(int arg0, View view, ViewGroup arg2) {
// TODO Auto-generated method stub
View v1 = view;
if (v1 == null) {
v1 = inflate.inflate(R.layout.item, null);
holder = new ViewHolder();
holder.txt_name = (TextView) v1.findViewById(R.id.item_name);
holder.src = (TextView) v1.findViewById(R.id.textView1);
holder.img = (ImageView) v1.findViewById(R.id.item_img);
v1.setTag(holder);
} else {
holder = (ViewHolder) v1.getTag();
}
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(arg0);
holder.txt_name.setText(song.get("name"));
return v1;
}
static class ViewHolder {
TextView txt_name,src;
ImageView img;
}
答案 0 :(得分:0)
这取决于您保存图像的方式 假设它是64base阵列你可以这样做
byte[] imageBytes = Base64.decode(song.getImageBytes(), Base64.DEFAULT);
Bitmap pic = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imageView.setImageBitmap(pic);
答案 1 :(得分:0)
“图像地址”是什么意思? 它是保存在您设备中的本地图像,本地路径存储在您的数据库或URL中,您需要下载图像吗?
如果是本地路径:Show Image View from file path?
如果您有网址,则需要下载图片:How to load an ImageView by URL in Android?