Can't upload image using Picasso as fragment

I have a snippet that supposedly fills the background with Imageview created with Picasso.

public class Fragment1 extends SherlockFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        Context c = getActivity().getApplicationContext();
        View myFragmentView = inflater.inflate(R.layout.home, container, false);
        TextView text = (TextView) myFragmentView.findViewById(R.id.text);

        ImageView imageView = (ImageView) myFragmentView.findViewById(R.id.image);
        String url = ModalScreens.byId(1).getBackgroundImagePath();
        Picasso.with(c).load(url).fit().into(imageView);
        return myFragmentView;
    }
}

I cannot understand what I am doing wrong, but the image will not load.

+4
source share
1 answer

From your code, it seems possible that you are downloading a local resource, not from the Internet. If this is the first case, you can simply download it as

fooobar.com/questions/29828 / ...

If not, and you are uploading a web image, then this can be a lot of problems, here are some hopefully useful troubleshooting methods.

  • Have you added?

<uses-permission android:name="android.permission.INTERNET"></uses-permission>

  1. ( adavis)? , .

Log.wtf("Testing valid URL", "|"+url+"|")

  1. ? .

  2. ? , - , android:src="@mipmap/large xml ImageView

0

All Articles