ViewHolder views must not be attached when created : <p>I'm trying to create a simple RV that will show a TextView.
This is my adapter:</p>

<pre><code>public class MyRvAdapter extends RecyclerView.Adapter&lt;MyRvAdapter.ViewHolder&gt; {

private String[] mDataset;


public static class ViewHolder extends RecyclerView.ViewHolder {
    // each data item is just a string in this case
    public TextView mTextView;
    public ViewHolder(TextView v) {
        super(v);
        mTextView = v;
    }
}

public MyRvAdapter(String[] myDataset) {
    mDataset = myDataset;
}

@NonNull
@Override
public MyRvAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.text_row_item, parent, false);
    TextView userNameInList= v.findViewById(R.id.display_name);
    ViewHolder vh = new ViewHolder(userNameInList);
    return vh;
    }

@Override
public void onBindViewHolder(@NonNull MyRvAdapter.ViewHolder holder, int position) {
    holder.mTextView.setText(mDataset[position]);
}

@Override
public int getItemCount() {
    return mDataset.length;
}
</code></pre>

<p>}</p>

<p>text_row_item is just a FrameLayout with a TextView inside it("display_name").
This is the eror:</p>

<pre><code>java.lang.IllegalStateException: ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot)
    at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6687)
    at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5869)
</code></pre>

<p>Thank you very much!</p>
