Johann
Johann

Reputation: 29867

onSupportNavigateUp not called when no Actionbar is used

I am using a toolbar but without an Actionbar or a AppBarLayout. Pressing on the Up (Back) button arrow in the top left corner does not trigger the onSupportNavigateUp method. One Stackoverflow ticket indicates that if you override onOptionsItemSelected, it will not be called. So I removed onOptionsItemSelected. But that didn't help. Here's my code:

setSupportActionBar(toolbar)
supportActionBar!!.setDisplayHomeAsUpEnabled(true)

xml layout:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#00FFFFFF"/>

Upvotes: 0

Views: 774

Answers (1)

Johann
Johann

Reputation: 29867

In onCreateOptionsMenu I was returning false, which prevents onSupportNavigateUp from being called. I returned false because I needed to hide the overflow menu (3 dots in the upper right corner). Looks like I'll have to find another way of hiding that menu.

Upvotes: 1

Related Questions