Java Class or Fragment
/*=============== Toolbar Section =====================*/ MaterialToolbar toolbar = findViewById(R.id.materialToolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.bus); actionBar.setHomeAsUpIndicator(R.drawable.back_arrow); // Set custom drawable } toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); // Handle back button click event } });