title: A difficulty with RecyclerView Adapter after update to API 27
body: <p>Everything was fine until I updated Sdk Version to 27. It says here that ViewHolder views must not be attached when created. But the attachToRoot parameter in my LayoutInflater is already set 'true'. Please explain me what could have caused this problem?
   <strong>Logcat</strong>:</p>
  
  <pre><code>06-02 11:40:15.669 22801-22801/com.bestworldgames.bestwordgame E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.bestworldgames.bestwordgame, PID: 22801
  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)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5752)
  at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5748)
  at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2232)
  at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556)
  at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
  at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
  at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
  at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
  at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3225)
  at android.view.View.measure(View.java:18788)
  at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
  at android.view.View.measure(View.java:18788)
  at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
  at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
  at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
  at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
  at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
  at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
  at android.view.View.measure(View.java:18788)
  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
  at android.view.Choreographer.doCallbacks(Choreographer.java:670)
  at android.view.Choreographer.doFrame(Choreographer.java:606)
  </code></pre>
  
  <p>Here is my <strong>RecyclerView Adapter</strong>:</p>
  
  <pre><code>public class GameTableAdapter extends RecyclerView.Adapter&lt;GameTableAdapter.ViewHolder&gt; {
  
  
  private ArrayList&lt;Litera&gt; literas;
  private LayoutInflater mInflater;
  private Map&lt;Integer, Integer&gt; hashMap;
  private Context context;
  private ArrayList&lt;Button&gt; adapterItems;
  private View mainView;
  private int itemSize;
  
  public GameTableAdapter(Context context, ArrayList&lt;Litera&gt; literas, Map&lt;Integer, Integer&gt; hashMap, int itemSize) {
      this.mInflater = LayoutInflater.from(context);
      this.literas = literas;
      this.hashMap = hashMap;
      this.context = context;
      this.adapterItems = new ArrayList&lt;&gt;();
      this.itemSize = itemSize;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = mInflater.inflate(R.layout.but_item, parent, false);
      parent.removeView(view);
      parent.addView(view);
      mainView = parent;
      return new ViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, final int position) {
      char mChar = literas.get(position).getCharValue();
      holder.item.setText(String.valueOf(mChar));
      if (this.hashMap.containsKey(position) &amp;&amp; (hashMap.get(position)!=null)) {
          setImg(hashMap.get(position), holder.item);
          holder.item.setTextColor(context.getResources().getColor(R.color.colorWhite));
      }
  }
  
  @Override
  public int getItemCount() {
      return literas.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder {
      Button item;
      ViewHolder(View itemView) {
          super(itemView);
          item = (Button) itemView.findViewById(R.id.item);
          item.setLayoutParams(new RecyclerView.LayoutParams(itemSize, itemSize));
          item.setTextSize(TypedValue.COMPLEX_UNIT_PX,(float)itemSize/2);
          adapterItems.add(item);
      }
  
  }
  
  public Litera getItem(int id) {
      return literas.get(id);
  }
  
  public Button getButItem(int id) {
      return adapterItems.get(id);
  }
  
  public View getMainView() {
      return mainView;
  }
  
  public void animateItem(int id) {
      adapterItems.get(id).setVisibility(View.INVISIBLE);
      adapterItems.get(id).setVisibility(View.VISIBLE);
  }
  
  }
  </code></pre>
  
  <p>in <strong>Fragment</strong>:</p>
  
  <pre><code>    recyclerView = (TouchableRecyclerView) rootView.findViewById(R.id.rv_chars);
  </code></pre>
  
  <p>...</p>
  
  <pre><code>public void setUpAdapter() {
          numberOfColumns = col;
          int itemSize = screenWidth / numberOfColumns;
          recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), numberOfColumns));
          adapter = new GameTableAdapter(getActivity(), literas, hashMapAllColors, itemSize);
          recyclerView.setAdapter(adapter);
          recyclerView.setNestedScrollingEnabled(false);
          recyclerView.setOnTouchListener(this);
      }
  </code></pre>
  
  <p><strong>TouchableRecyclerView.java</strong></p>
  
  <pre><code>public class TouchableRecyclerView extends RecyclerView {
      public TouchableRecyclerView(Context context) {
          super(context);
      }
  
      public TouchableRecyclerView(Context context, @Nullable AttributeSet attrs) {
          super(context, attrs);
      }
  
      public TouchableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      public boolean performClick() {
          return super.performClick();
      }
  
  }
  </code></pre>
  
  <p><strong>in xml</strong>:</p>
  
  <pre><code> &lt;com.bestworldgames.bestwordgame.widgets.TouchableRecyclerView
          android:id="@+id/rv_chars"
          android:layout_below="@+id/tapped_word"
          android:paddingLeft="5dp"
          android:layout_centerHorizontal="true"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:overScrollMode="never"
          android:clickable="true"
          android:focusable="true"
          android:longClickable = "false"&gt;
  
      &lt;/com.bestworldgames.bestwordgame.widgets.TouchableRecyclerView&gt;
  </code></pre>
  
  <p><strong>but_item.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Button xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/item"
      android:paddingRight="6dp"
      android:paddingBottom="8dp"
      android:animateLayoutChanges="true"
      android:layout_width="50dp"
      android:layout_height="50dp"
      android:background="@drawable/button_color_1"
      android:longClickable="false"
      android:clickable="false"
      android:focusable="false"&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <blockquote>
    <p>This error occurs after working constructor
    <code>public ViewHolder(View itemView)</code> and before method
    <code>onBindViewHolder(ViewHolder holder, final int position)</code>. 
    That's all I can say at the moment.</p>
  </blockquote>