title: Kotlin direct access to Button in android.support.v4.app.Fragment null object reference
body: <p>I'm trying to get direct access to a button in a fragment (android.support.v4) and this is what it's throwing:  </p>
  
  <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
  at             
  com.....fragments.HomeFragment._$_findCachedViewById(HomeFragment.kt)
  at 
  com.....fragments.HomeFragment.onCreateView(HomeFragment.kt:25)
  </code></pre>
  
  <p>This is the button I'm trying to get access to in fragment_home.xml:</p>
  
  <pre><code>&lt;Button
      android:id="@+id/batteryInstallationButton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/battery_installation"
      android:layout_weight="1"
      android:textSize="12sp"
      android:background="@drawable/custom_button"
      android:textColor="@color/white"
      android:layout_marginStart="5dp"
      android:layout_marginEnd="5dp"/&gt;
  </code></pre>
  
  <p>This is the Kotlin code in HomeFragment.kt</p>
  
  <pre><code>import android.content.Context
  import android.net.Uri
  import android.os.Bundle
  import android.support.v4.app.Fragment
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  import android.widget.Toast
  
  import kotlinx.android.synthetic.main.fragment_home.*
  
  class HomeFragment : Fragment() {
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
  }
  
  override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
                            savedInstanceState: Bundle?): View? {
      val rootView = inflater!!.inflate(R.layout.fragment_home, container, false)
  
      batteryInstallationButton?.setOnClickListener {
          Toast.makeText(context, "ehere", Toast.LENGTH_SHORT).show();
      }
  
      return rootView
  }
  
  companion object {
  
      fun newInstance(): HomeFragment {
          val fragment = HomeFragment()
          return fragment
      }
  }
  
  }
  </code></pre>
  
  <p>Anyone know why I can't get the direct access to the Button?</p>