Quantcast
Channel: onCreateOptionsMenu is never called - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by Ahamadullah Saikat for onCreateOptionsMenu is never called

$
0
0

If above answer doesn't work, make sure that you are using the same id of toolbar.

layout_app_bar.xml

<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    android:id="@+id/toolbar"    android:layout_width="match_parent"    android:layout_height="?attr/actionBarSize">

activiy_main.xml

<include    android:id="@+id/app_bar"    layout="@layout/layout_app_bar" />

in java file:

don't call:

Toolbar tb = findViewById(R.id.toolbar);

please call:

Toolbar tb = findViewById(R.id.app_bar);

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>