Android Picasso无法获取图像,但会占位符

时间:2019-01-26 16:33:57

标签: android picasso

我无法让Picasso与<style> paper-input { --paper-input-container-input-webkit-spinner: { -webkit-appearance: none; } --paper-input-container-shared-input-style: { width: 50px; -webkit-appearance: textfield; } width: 50px; } </style> 一起使用。它正在加载占位符,而不是URL中的图像。

活动

RecyclerView.Adapter

新闻类

public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.NewsViewHolder> {

    private List<News> mNews;
    private Context    mContext;

    public NewsAdapter(List<News> mNews, Context mContext) {
        this.mNews = mNews;
        this.mContext = mContext;
    }

    @NonNull
    @Override
    public NewsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.news_list_item, parent, false);
        return new NewsViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull NewsViewHolder holder, int position) {

        News news = mNews.get(position);

        holder.itemSection.setText(news.getmSectionName());
        holder.itemDate.setText(news.getmWebPublicationDate());
        holder.itemHeadline.setText(news.getmHeadline());
        Picasso.get().load(news.getmThumbnail()).placeholder(R.drawable.ic_launcher_background).into(holder.itemThumbnail);

    }

    @Override
    public int getItemCount() {
        return mNews.size();
    }

    /**
     * ViewHolder Class
     */
    public class NewsViewHolder extends RecyclerView.ViewHolder {

        public TextView  itemSection;
        public TextView  itemDate;
        public TextView  itemHeadline;
        public ImageView itemThumbnail;
        public TextView  itemContributor;

        public NewsViewHolder(@NonNull View itemView) {
            super(itemView);

            itemSection = itemView.findViewById(R.id.news_item_section);
            itemDate = itemView.findViewById(R.id.news_item_date);
            itemHeadline = itemView.findViewById(R.id.news_item_headline);
            itemThumbnail = itemView.findViewById(R.id.news_item_thumbnail);
            itemContributor = itemView.findViewById(R.id.news_item_contributor);
        }
    }

}

0 个答案:

没有答案