Note that there are some explanatory texts on larger screens.

plurals
  1. POI Use ShareActionProvider in PopupMenu, but show two PopupMenu?
    text
    copied!<p>I use a ShareActionProvider in a PopupMenu, but when I click the share menu item, it shows two PopupMenus on the screen, one covered by the other. And one shows the application icon and name, the other one only shows the application name. </p> <p>It works fine except this problem...<br> How can I fix it?</p> <p>P.S.: please forgive me for my bad expression</p> <p>My code is:</p> <pre><code>PopupMenu popup = new PopupMenu(this, button); popup.getMenuInflater().inflate(R.menu.scrawl_popup_menu, popup.getMenu()); MenuItem overflowItem = popup.getMenu().findItem(R.id.popup_share); ShareActionProvider overflowProvider = (ShareActionProvider) overflowItem.getActionProvider(); overflowProvider.setShareHistoryFileName( ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); overflowProvider.setShareIntent(createShareIntent()); </code></pre> <p>menu.xml is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@+id/popup_clear" android:icon="@drawable/ic_menu_clear" android:title="@string/popup_menu_clear" /&gt; &lt;item android:id="@+id/popup_insert_bg" android:icon="@drawable/ic_menu_insert_bg" android:title="@string/popup_menu_insert_bg"/&gt; &lt;item android:id="@+id/popup_share" android:icon="@android:drawable/ic_menu_share" android:title="@string/popup_menu_share" android:actionProviderClass="android.widget.ShareActionProvider"&gt; &lt;/item&gt; &lt;/menu&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload