无法在毕加索的空上下文中启动加载

时间:2017-03-09 09:29:31

标签: android android-recyclerview adapter picasso

请有人解决此错误

  

java.lang.IllegalArgumentException:您无法在空上下文上启动加载

public class CompteAdapter extends RecyclerView.Adapter<CompteAdapter.MyViewHolder> {

    private Context mContext;
    private List<CompteWrapper> compteList;
    private AdapterView.OnItemClickListener onItemClickListener;

    public CompteAdapter(Context mContext, AdapterView.OnItemClickListener onItemClickListener, List<CompteWrapper> compteList) {
        this.mContext = mContext;
        this.compteList = compteList;
        this.onItemClickListener = onItemClickListener;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.compte_carte, parent, false);

        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        CompteWrapper compte = compteList.get(position);
        holder.title.setText(compte.getName());

        Picasso.with(this.mContext).load(compte.getIcon()).into(holder.icon);
    }
}

1 个答案:

答案 0 :(得分:-1)

使用getApplicationContext()或getBaseContext()