I want to place images on every page of my ViewPager (e.g. books). These images were obtained from the URL list:
My adapter looks like this:
private class MyPagerAdapter extends PagerAdapter{ @Override public int getCount() { return NUM_AWESOME_VIEWS; } @Override public Object instantiateItem(View collection, int position) {
and I take these images thanks to asintet:
private class CreateImage extends AsyncTask<String, Void, Drawable> { ImageView image; public CreateImage(ImageView img) { image = img; } protected void onPreExecute() { } protected Drawable doInBackground(String... urls) { InputStream is; Drawable d = null ; try { is = (InputStream)new URL(urls[0]).getContent(); d = Drawable.createFromStream(is, "Image"); return d; } catch (MalformedURLException e) {
The fact is that it does not work at all.
source share