title: onclick using databinding in fragment
body: <p>I am trying to implement data binding in a Fragment but it's not working, the same code is working in Activity.</p>
  
  <p>Fragment class</p>
  
  <pre><code>    final FragmentHomeBinding fragmentHomeBinding = DataBindingUtil.inflate(
              inflater, R.layout.fragment_home, container, false);
  
      homeViewModel = ViewModelProviders.of(this).get(HomeViewModel.class);
      View root = inflater.inflate(R.layout.fragment_home, container, false);
      fragmentHomeBinding.setVariable(BR.homeViewModel, homeViewModel);
      HomeEventHandler homeEventHandler = new HomeEventHandler(getActivity());
      fragmentHomeBinding.setHandler(homeEventHandler);
  </code></pre>
  
  <p>EventHandlerClass</p>
  
  <pre><code>HomeEventHandler(Context mContext) {
      this.mContext = mContext;
  }
  
  public void onButtonClick(View view) {
      Log.e("DB", "onButtonClick: ");
      switch (view.getId()){
          case R.id.frag_home_ll_stock:
              Toast.makeText(mContext, "clicked", Toast.LENGTH_SHORT).show();
              Intent intent = new Intent(mContext, StockCheckActivity.class);
              mContext.startActivity(intent);
      }
  }
  </code></pre>
  
  <p>and finally the xml file</p>
  
  <pre><code>&lt;data&gt;
  
      &lt;import type="android.view.View" /&gt;
  
      &lt;variable
          name="fragment"
          type="com.poc.ui.home.HomeFragment"/&gt;
  
      &lt;variable
          name="handler"
          type="com.poc.ui.home.HomeEventHandler"/&gt;
  
  &lt;/data&gt;
  
                  &lt;LinearLayout
                      android:onClick="@{view-&gt;handler.onButtonClick(view)}"
                      android:id="@+id/frag_home_ll_stock"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_weight="1"
                      android:background="@color/grey_25"
                      android:clickable="true"
                      android:focusable="true"
                      android:gravity="center_horizontal"
                      android:orientation="vertical"
                      android:padding="16dp"&gt;
                      &lt;!--
                      --&gt;
                      &lt;TextView
                          android:id="@+id/frag_home_tv_op4"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_margin="8dp"
                          android:clickable="false"
                          android:text="@string/w_stock_check"
                          android:textColor="@color/black"
                          android:textSize="18sp" /&gt;
  
                      &lt;ImageView
                          android:id="@+id/frag_home_iv_op4"
                          android:layout_width="72dp"
                          android:layout_height="72dp"
                          android:layout_marginTop="8dp"
                          android:layout_marginBottom="8dp"
                          android:clickable="false"
                          app:srcCompat="@drawable/ic_stock" /&gt;
  
  
                  &lt;/LinearLayout&gt;
  </code></pre>