title: how to add back button on toolbar android kotlin
body: <p>I'm now to android, I am trying to add back button on toolbar using kotlin, tried almost every way posted on online, it just doesn't work at all, always crash for unknown reasons. Can anyone help?</p>
  <pre><code>class MainActivity : BaseActivity() {
  
  
    override fun getLayoutId(): Int {
        return  R.layout.activity_main
    }
  
    override fun initData() {
      super.initData()
  
      val testButton = findViewById&lt;Button&gt;(R.id.testButton)
  
      testButton.setOnClickListener{
          startActivity&lt;RegistrationActivity&gt;()
      }
  
    }
  
  }
  
  &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 
     xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
     xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
     xmlns:tools=&quot;http://schemas.android.com/tools&quot;
     android:layout_width=&quot;match_parent&quot;
     android:layout_height=&quot;match_parent&quot;
     tools:context=&quot;.MainActivity&quot;&gt;
  
  
  &lt;include android:id=&quot;@+id/navBarView&quot; layout=&quot;@layout/toolbar&quot;/&gt;
  
  &lt;Button
      android:id=&quot;@+id/testButton&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginTop=&quot;92dp&quot;
      android:layout_marginBottom=&quot;533dp&quot;
      android:height=&quot;50dp&quot;
      android:text=&quot;click me&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/navBarView&quot; /&gt;
  
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>// below is the toolbar xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.appcompat.widget.Toolbar 
     xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
     xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
     android:id=&quot;@+id/toolbar&quot;
     android:layout_width=&quot;match_parent&quot;
     android:layout_height=&quot;?attr/actionBarSize&quot;
     android:background=&quot;@color/white&quot;
     app:titleTextColor=&quot;@color/white&quot;
     app:popupTheme=&quot;@style/ThemeOverlay.AppCompat.ActionBar&quot; &gt;
  
  &lt;TextView
      android:layout_width=&quot;150dp&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:src=&quot;@mipmap/title_view_image&quot;
      android:layout_centerVertical=&quot;true&quot;
      android:layout_gravity=&quot;center&quot;
      android:gravity=&quot;center&quot;
      android:text=&quot;Toolbar&quot; /&gt;
  
  &lt;/androidx.appcompat.widget.Toolbar&gt;
  
  
  
  class RegistrationActivity: BaseActivityWithBinding&lt;ActivityRegistrationBinding&gt;() {
  
     private lateinit var viewModel: UserViewModel
  
     override fun onCreated(savedInstanceState: Bundle?) {
  
        initToolbar()
  
        val factory = UserViewModelFactory()
        viewModel = ViewModelProviders.of(this,factory).get(UserViewModel::class.java)
        binding.myHandle = viewModel
        binding.lifecycleOwner = this
  
        viewModel.isStringEmpty.observe(this, Observer {
           if(it == true){
              showAlert()
           }
        })
  
  }
  
  fun initToolbar(){
  
      val toolbar = findViewById&lt;Toolbar&gt;(R.id.toolbar);
      setSupportActionBar(toolbar)
      supportActionBar?.apply {
          setDisplayShowHomeEnabled(false)
          setHomeAsUpIndicator(R.drawable.ic_baseline_keyboard_arrow_down_24)
      }
  
  }
  </code></pre>
  <p>the back button doesn't show, I see different solutions online, and I tried them all, it doesn't work, can anyone check if I miss something or ?</p>