-1

I have the menu icon (3 dots) duplicated I used the following code:

@Override public boolean onPrepareOptionsMenu(final Menu menu) {
menu.clear();
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return super.onCreateOptionsMenu(menu);

}

but it didn't solve my problem is it because I'm using androidx libraries? My XML code for the menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto">
 <item android:title="more"
    android:id="@+id/moreVertical"
    android:icon="@drawable/baseline_more_vert_black_18dp"
    app:showAsAction="always" />
    <item android:title="@string/titlecontactus" android:id="@+id/mnuContactUs"/>
<item android:title="@string/titlepolicy" android:id="@+id/mnuPolicy"/>

my toolbar XML code in the activity:

   <androidx.appcompat.widget.Toolbar
    android:id="@+id/my_toolbar" app:title="@string/title"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimaryDark"
    android:elevation="4dp"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

</androidx.appcompat.widget.Toolbar>
TheEagle
  • 21
  • 7
  • https://stackoverflow.com/questions/28317905/android-toolbar-menu-is-not-showing – Usama Altaf Feb 02 '21 at 12:19
  • Does this answer your question? [Android toolbar menu is not showing](https://stackoverflow.com/questions/28317905/android-toolbar-menu-is-not-showing) – Usama Altaf Feb 02 '21 at 12:19
  • No my menu item show up but it is duplicated the 3 dots show up twice and onPrepareOptionsMenu didn't solve my problem.I observed using showAsAction=never solve the problem but it cause the 3 dots item title to show up which is more I don't want more item to show up – TheEagle Feb 02 '21 at 14:18

1 Answers1

0

I just removed the item I made for 3 dots which has the title more and everything worked fine it seems the 3 dots appear by default and no need to add an item for it or download its 3 dots image.It seems the article I followed was wrong or may be out of date.Hope someone could help on my second question: Copy sqlite in android studio assets not working

TheEagle
  • 21
  • 7