How to consume data online in an Adapter

Asked

Viewed 23 times

0

With this Adapter code below I created a gallery that works without problem, but instead of consuming the images of Drawable I want you to consume the images that are on the web. Does anyone know how to get this result?

public class GaleriaImagensAdapter extends PagerAdapter {

private Context context;
private int[] imagens = new int[] { R.drawable.min_interface_13, R.drawable.min_interface_14, R.drawable.min_interface_132 };

GaleriaImagensAdapter(Context context) {
    this.context = context;
}

@Override
public int getCount() {
    return imagens.length;
}

@Override
public boolean isViewFromObject(View view, Object object) {
    return view.equals(object);
}

@Override
public void destroyItem(ViewGroup pager, int position, Object object) {
    ((ViewPager) pager).removeView((ImageView) object);
}

@Override
public Object instantiateItem(ViewGroup pager, int position) {
    ImageView imagem = new ImageView(context);
    imagem.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imagem.setImageResource(imagens[position]);
    ((ViewPager) pager).addView(imagem, 0);
    return imagem;
}
  • You need to send the list (of image urls) to your adpter by the builder

  • This is the point, there is no way to build this list with the image url, because I want to take the images from a Facebook page and upload inside the gallery. Facebook has an API that makes the release, but I can’t implement a code that shows the images in the app

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.