private void dispalyImage(final String picUrl, final ImageView imageView) { AsyncTask<Void, Void, Bitmap> asyncTask = new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { try { URL url=new URL(picUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setReadTimeout(5000); connection.setConnectTimeout(5000); int responseCode = connection.getResponseCode(); while (responseCode==200){ InputStream inputStream = connection.getInputStream(); Bitmap bitmap= BitmapFactory.decodeStream(inputStream); return bitmap; } } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bitmap) { imageView.setImageBitmap(bitmap); } }; asyncTask.execute(); } class ViewHolder{ ImageView imageView; TextView text_title; TextView text_time; }