This is the method i wrote to get image from url to bitmap, and i have made to run whenever i scroll down the main view using Handler
public void setimage(final ImageView imageview, final String urll,final int postion)
{
new Thread(new Runnable()
{
@Override
public void run()
{
URL url = null;
try {
url = new URL(urll);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
final Bitmap myBitmap = BitmapFactory.decodeStream(input);
handler.post(new Runnable()
{
@Override
public void run() {
imageview.setImageBitmap(Bitmap.createScaledBitmap(myBitmap, 160, 140, true));
}
});
web.get(postion).setImage(myBitmap);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}).start();
}
This is the exception i am getting in Custom adapter whenever i scroll down to view more images in logcat
java.lang.OutOfMemoryError android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
Please let me know where i am doing wrong