-1

I want to set image address that is stored in database to image view

I have this code but I don't know do it, I get name column to TextView but I can't set image address to imageview

Please help me!

Source code:

@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;


}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mehdi Rahimi
  • 153
  • 2
  • 13

2 Answers2

0

it depends on how you saved your image assuming it's 64base array you can do like that

byte[] imageBytes = Base64.decode(song.getImageBytes(), Base64.DEFAULT);
Bitmap pic = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imageView.setImageBitmap(pic);
Muhannad Fakhouri
  • 1,468
  • 11
  • 14
0

What do you mean with "image adress" ? Is it a local image saved in your device with local path stored in your database or an URL and you need to download the image ?

If local path : Show Image View from file path?

If you have an URL and you need to download image : How to load an ImageView by URL in Android?

Community
  • 1
  • 1
Bubu
  • 1,533
  • 14
  • 14