-2

i want to set image in imageview with URL

i am converting server image to bitmap then putting it on imageview in my listview adapter used in a BaseAdapter

try {
            Log.d("AdapterGetView", "threadAvatarURL = " + threadAvatarURL);
            URL url = new URL(Config.HOST_NAME +threadAvatarURL);
            Bitmap image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
            holder.profileImage.setImageBitmap(image);

        } catch (Exception e) {
            //txtUrl.setText("Error: Exception");
        }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Vipin Saini
  • 39
  • 1
  • 2
  • 9

1 Answers1

0

Easier way Use Picasso library: download the picasso jar file and import on project and use this codes :

   ImageView img = (ImageView) findViewById(R.id.image);

 Picasso.with(getApplicationContext()).load("Your image Address").memoryPolicy(MemoryPolicy.NO_CACHE).transform(new CircleTransform()).into(img);