Search code examples
androidandroid-fragmentspicasso

Picasso doesnot show placeholder, error and url image in imageview of fragment


I am trying to download a image into a imageview in a fragment but it doesnot show any image in the imageview, not even placeholder and error image. my code is the following in fragment

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



        View view = inflater.inflate(R.layout.fragment_one, container, false);
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
        Context c = getActivity().getApplicationContext();
       Picasso.with(c)
                .load("http://inthecheesefactory.com/uploads/source/glidepicasso/cover.jpg").
        placeholder(R.drawable.aa).error(R.drawable.ab)
                .into(imageView);

        return inflater.inflate(R.layout.fragment_one, container, false);
    }

when i try to use the same code in an normal activity everything works. the problem only seems with in the fragment activity. i am using the imageview in swipe view of material design.


Solution

  • You can try this, instead of this

         return inflater.inflate(R.layout.fragment_one, container, false);
    

    try

              return view;