I am getting below error log:
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) {
}
}
I am also referring Butterknife is unable to bind inside my Adapter Class
Also see ButterKnife.bind(this, itemView); related issue.
But it can't helps me. Am I missing something, or doing something wrongly?
You can try below code:
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);
}
}