title: How to get an adapter item object from a LayoutManager view (RecyclerView)
body: <p>I'm using <code>RecyclerView</code> to which I attach a <code>LinearLayoutManager</code> and a <code>RecyclerView.Adapter</code></p>
  
  <pre><code>    RecyclerView conversationList = (RecyclerView)findViewById(R.id.conversationList);
      LinearLayoutManager layoutManager = new LinearLayoutManager(this);
      conversationList.setLayoutManager(layoutManager);
      MessagesAdapter adapter = new MessagesAdapter();
      conversationList.setAdapter(adapter);
  </code></pre>
  
  <p>In <code>onBindViewHolder</code> of <code>RecyclerView.Adapter</code> I'm passing the adapter item object to the view by using setTag:</p>
  
  <pre><code>    @Override
      public void onBindViewHolder(ViewHolder viewHolder, int position) {
          viewHolder.itemView.setTag(getItem(position));
          ...
      }
  </code></pre>
  
  <p>I'm iterating over child views of the <code>layoutManager</code> and get the needed object by using the <code>getTag</code> method</p>
  
  <pre><code>        for (int i = 0; i &lt; layoutManager.getChildCount(); i++) {
              LinearLayout container = (LinearLayout)layoutManager.getChildAt(i);
              LinearLayout container2 = (LinearLayout)container.getChildAt(0);
              Object tag = container2.getTag();
          }
  </code></pre>
  
  <p>It doesn't seem right to me. Is there a better way of doing this?</p>