【问题标题】:Picasso doesnot show placeholder, error and url image in imageview of fragmentPicasso 在片段的 imageview 中不显示占位符、错误和 url 图像
【发布时间】:2017-10-05 06:48:21
【问题描述】:

我正在尝试将图像下载到片段中的图像视图中,但它在图像视图中不显示任何图像,甚至不显示占位符和错误图像。我的代码片段如下

 @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);
    }

当我尝试在正常活动中使用相同的代码时,一切正常。问题只出现在片段活动中。我在 Material Design 的滑动视图中使用 imageview。

【问题讨论】:

    标签: android android-fragments picasso


    【解决方案1】:

    你可以试试这个, 而不是这个

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

    试试

              return view;
    

    【讨论】:

    • 乐于帮助@sagar.acharya
    猜你喜欢
    • 2015-06-27
    • 2017-08-02
    • 1970-01-01
    • 2011-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多