title: RecyclerView Databinding Item click
body: <p>I am trying to listen for row clicks (item clicks) on my recycler view from the Activity itself (not from adapter).</p>
  
  <p>My Adapter so far looks like this:</p>
  
  <pre><code>public class ListMiestnostiAdapter extends RecyclerView.Adapter&lt;ListMiestnostiAdapter.ViewHolder&gt;{
      private List&lt;Miestnost&gt; data;
  
      // you provide access to all the views for a data item in a view holder
      public static class ViewHolder extends RecyclerView.ViewHolder {
          public ViewDataBinding binding;
  
          public ViewHolder(ViewDataBinding binding) {
              super(binding.getRoot());
              this.binding = binding;
          }
  
          public void bind(Object obj){
              binding.setVariable(BR.obj, obj);
              binding.executePendingBindings();
          }
      }
  
      public ListMiestnostiAdapter(List&lt;Miestnost&gt; data) {
          this.data = data;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          // create a new view
          LayoutInflater inflater = LayoutInflater.from(parent.getContext());
          ActivityListMiestnostiRowBinding itemBinding = ActivityListMiestnostiRowBinding.inflate(inflater, parent,false);
  
          return new ViewHolder(itemBinding);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          Miestnost item = data.get(position);
          holder.bind(item);
      }
  
      @Override
      public int getItemCount() {
          return data.size();
      }
  }
  </code></pre>
  
  <p>And my row layout like this:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:bind="http://schemas.android.com/apk/res-auto"&gt;
      &lt;data&gt;
          &lt;variable
              name="obj"
              type="com.example.com.projectname.Models.Miestnost" /&gt;
      &lt;/data&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="?android:attr/selectableItemBackground"
          android:clickable="true"
          android:focusable="true"
          android:orientation="horizontal"
          android:paddingBottom="@dimen/row_padding_vertical"
          android:paddingLeft="@dimen/activity_horizontal_margin"
          android:paddingRight="@dimen/activity_horizontal_margin"
          android:paddingTop="@dimen/row_padding_vertical"&gt;
  
          &lt;TextView
              android:id="@+id/txt_miestnost_row_nazov"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentTop="true"
              android:text="@{obj.Name}"
              android:textSize="16dp" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>As I have already mentioned I am trying to listen to item clicks, but not from Adapter itself (as other posts suggested), but from my Activity which holds this RecyclerView. </p>
  
  <p>Is such action even possible? If yes, then any help would be highly appreciated as I could not find anything on google.</p>