bitmap Images not displaying in viewpager android

In my android app I am using a tab swipe view having 4 tabs first 2 tabs displays text, in next 2 tabs I need to display bitmap images which I get from server after some background processing.Problem is bitmaps object are available in the list but not displaying.

Please see the below code

public class PhotoBeforeFoe extends Fragment {
     ImageView imageView;
     ExistingData existingData;
     ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>();
     int count;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {

        View rootView = inflater.inflate(, container, false);        
        ViewPager viewPager = (ViewPager) rootView.findViewById(;      
        imageView= new ImageView(getActivity());
        String[] imagePath=getArguments().getStringArray("beforeImage");
        ImageLoader imageLoader = new ImageLoader(getActivity());
    /*  int i=0;
        for(Bitmap b :bitmaps){
             d[i]=new BitmapDrawable(getResources(),bitmaps.get(i));
        //Drawable d = new BitmapDrawable(getResources(),bitmaps.get(0));

        ImagePagerAdapter adapter = new ImagePagerAdapter();        

        return rootView;

      private class ImagePagerAdapter extends PagerAdapter {

            public int getCount() {
              return d.length;

            public boolean isViewFromObject(View view, Object object) {
              return view == ((ImageView) object);

            public Object instantiateItem(ViewGroup container, int position) {
              Context context = PhotoBeforeFoeFragment.this.getActivity();
              ImageView imageView = new ImageView(context);
           // imageView.setImageDrawable(d[position]);
              ((ViewPager) container).addView(imageView);
              return imageView;
            public int getItemPosition(Object object) {
                return POSITION_NONE;

            public void destroyItem(ViewGroup container, int position, Object object) {
              ((ViewPager) container).removeView((ImageView) object);



Please provide inputs I m stuck here.


If you load your images in onCreateView by async processing, they cannot be displayed at the moment because they have not loaded. If you want to set it in instantiateItem, you need to refresh your adapter’s item after image loaded.

The solution is to delete all your image loading code and use Picasso loader in instantiateItem:

Picasso.with(context).load(/*your url*/url).into(/*ImageView*/imgView);