无法在 ButterKnife.bind(this, itemView) 为 .. $RecyclerViewHolders 绑定视图;在 RecyclerViewHolders 中

Unable to bind views for .. $RecyclerViewHolders at ButterKnife.bind(this, itemView); in RecyclerViewHolders

我收到以下错误日志:

java.lang.RuntimeException: Unable to bind views for .. $RecyclerViewHolders at butterknife.ButterKnife.bind(ButterKnife.java:322) at butterknife.ButterKnife.bind(ButterKnife.java:279) ... at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5482) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4707) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994) at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1390)

public class RecyclerViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener {

    private Context mContext;


    @Bind(R.id.tvRowServiceCenterName)
    CustomTextView tvRowServiceCenterName;
    @Bind(R.id.tvRowServiceCenterKmsValue)
    CustomTextView tvRowServiceCenterKmsValue;

    @Bind(R.id.ivRowServiceCenterImage)
    CircleImageView ivRowServiceCenterImage;
    @Bind(R.id.ivRowServiceCenterStatus)
    CircleImageView ivRowServiceCenterStatus;

    public RecyclerViewHolders(Context context, View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView); // Getting error here at runtime
        this.mContext = context;
        //itemView.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {

    }
}

我也指

另见 ButterKnife.bind(this, itemView); 相关问题。

但这对我没有帮助。我是漏掉了什么,还是做错了什么?

您可以试试下面的代码:

public static class ViewHolder extends RecyclerView.ViewHolder{
@Bind(R.id.tvRowServiceCenterName)
CustomTextView tvRowServiceCenterName;
@Bind(R.id.tvRowServiceCenterKmsValue)
CustomTextView tvRowServiceCenterKmsValue;
@Bind(R.id.ivRowServiceCenterImage)
CircleImageView ivRowServiceCenterImage;
@Bind(R.id.ivRowServiceCenterStatus)
CircleImageView ivRowServiceCenterStatus;

private ViewHolder(View view, int viewType, Context context){
        super(view);
        ButterKnife.bind(this, view);
    }
}