0

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?

Community
  • 1
  • 1
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
  • Can you post the adapter code and item xml code ? Have a look at this github issue comment https://github.com/JakeWharton/butterknife/issues/423#issuecomment-167086168 – Renaud Boulard Apr 25 '16 at 11:26
  • @RenaudBoulard . Thanks for link. As per link I tried my code with `try.. catch` but it can't help. – pRaNaY Apr 25 '16 at 11:46

1 Answers1

3

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);
    }
}
Riten
  • 2,879
  • 3
  • 24
  • 28