title: RecyclerView - get Position inside Activity rather than RecyclerViewAdapter
body: <p>It is my third day now dealing with the handling of my view clicks. I originally was using <code>ListView</code>, then I switched to <code>RecyclerView</code>. I have added <code>android:onclick</code> elements to every control on my <code>row_layout</code> and I am handling them in my <code>MainActivity</code> like this:</p>
  
  <pre><code>public void MyMethod(View view) {}
  </code></pre>
  
  <p>In my old <code>ListView</code> implementation, I have done <code>setTag(position)</code> to be able to get it in <code>MyMethod</code> by doing this inside it:</p>
  
  <pre><code>Integer.parseInt(view.getTag().toString())
  </code></pre>
  
  <p>This worked nicely without problems. Though now I am dealing with <code>RecyclerView</code> and being forced to use the <code>ViewHolder</code>, which does not offer a <code>setTag</code> method. After searching for 2 hours, I have found that people use <code>setTag</code> like this:</p>
  
  <pre><code>holder.itemView.setTag(position)
  </code></pre>
  
  <p>This was acceptable. Though when I try to get the value from the <code>MyMethod</code> function using the line:</p>
  
  <pre><code>Integer.parseInt(view.getTag().toString())
  </code></pre>
  
  <p>The application crashes. I have read several implementation of onclick handling inside the adapter which works but I have to use the <code>MainActivity</code> because I am using something that is unique to that activity.</p>
  
  <p>TL;DR I want to send the position of the clicked row to my <code>MainActivity</code> in a simple manner.</p>
  
  <p>Edit: I apologize for the confusion since my topic was not very thorough. I have a <code>RecyclerView</code> and an adapter. The adapter is linked to my <code>row_layout</code>. This <code>row_layout</code> xml has one root <code>LinearLayout</code>. Inside it there is one <code>TextView</code>, another <code>LinearLayout</code> (which has two <code>TextViews</code>) and one <code>Button</code> (for simplicity). I do not want to suffer for dealing with the clicks on <code>RecylerView</code> like I did with the <code>ListView</code>. So, I have decided to add an <code>android:onclick</code> for every control, then link <code>TextView</code> and <code>LinearLayout</code> to a single method and link the <code>Button</code> (and future <code>Button</code>s) to their unique methods. What I am missing is that I want to be able to tell the position on each of the receiving methods on my <code>MainActivity</code>. If I must link everything that comes from the adapter and goes into the <code>MainActivity</code> to a single onclick handler, so be it. Although, how would I tell which control fired the click?</p>
  
  <p>Edit 2: The requested layout</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:onClick="MyMethod"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:weightSum="1"&gt;
      &lt;TextView
          android:id="@+id/letter"
          android:onClick="MyMethod"
          android:layout_width="60dp"
          android:layout_height="fill_parent"
          /&gt;
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:onClick="MyMethod"
          android:layout_width="200dp"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/firstname"
              android:onClick="MyMethod"
              android:layout_width="fill_parent"
              android:layout_height="17dp" /&gt;
          &lt;TextView
              android:id="@+id/longname"
              android:onClick="MyMethod"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" /&gt;
  
      &lt;/LinearLayout&gt;
      &lt;Button
          android:text="Test"
          android:onClick="OtherMethod"
          android:layout_width="match_parent"
          android:layout_height="fill_parent"
          android:id="@+id/process"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>