毕加索语境错误

时间:2018-06-06 03:35:42

标签: android picasso

我正在使用fragement actitivty,但是上下文错误

Picasso.get(activity)

此行活动错误 Error Scrrenshot

 public void setdetails(FragmentActivity activity, String sitename, String sitelink, final String imageuri) {
        TextView District = (TextView) mview.findViewById(R.id.txtsitename);

        final ImageView imageView = (ImageView) mview.findViewById(R.id.imgsiteimage);


        Picasso.get(activity).load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback() {
            @Override
            public void onSuccess() {

            }

            @Override
            public void onError(Exception e) {
                Picasso.get().load(imageuri).placeholder(R.drawable.loadbar).into(imageView);
            }
        });

2 个答案:

答案 0 :(得分:0)

用这样的上下文替换活动

  File file = new File(filePath);

Picasso.with(context).load(file).placeholder(R.drawable.draw_detailed_view_display).error(R.drawable.draw_detailed_view_display)
    .resize(400, 400).into(mImageView, new Callback() {

        @Override
        public void onSuccess() {

        }

        @Override
        public void onError() {
            mImageView.setVisibility(View.GONE);
        }
    });

答案 1 :(得分:0)

activity移除get(),就像这样。

Picasso.get().load(imageuri).networkPolicy(NetworkPolicy.OFFLINE).into(imageView, new Callback() 

这将解决您的问题。