I\'ve created a Toolbar
for Lollipop, but I can\'t seem to figure out how to add an overflow button to the toolbar. I\'m not going to be using the v7 appcompat
If you want to add the item in the overflow menu you should set never
as android:showAsAction
. If you set always
the item will be an icon in the toolbar.
Edit your menu.xml
like this:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
android:showAsAction="never"
android:visible="true" />
</menu>
Also you need to call setActionBar()
. Edit initToolbar()
like this:
private void initToolbar() {
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitleTextColor(Color.WHITE);
mToolbar.setTitle("gnappo");
mToolbar.showOverflowMenu();
setActionBar(mToolbar);
}
If your toolbar is of the package android.support.v7.widget, use setSupportActionBar(mToolbar);
instead of setActionBar(mToolbar);