• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Call ShareActionProvider from a PopupMenu

hakiim

Lurker
I'm trying to use the ShareActionProvider from a PopupMenu which is displayed after clicking an item of a listView. The problem is that the share menu doesn't display the icons as they should be.

JKc8V.png


another problem appears when I click on the "see all" item, another share menu appears!

sLhMK.png

Code:
    public void openVideoMenu(View view) {
    	PopupMenu popup = new PopupMenu(this, view);
    	MenuInflater inflater = popup.getMenuInflater();
    	inflater.inflate(R.menu.video_menu, popup.getMenu());
    	
        ShareActionProvider mShareActionProvider = (ShareActionProvider) popup.getMenu().findItem(R.id.share).getActionProvider();
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_TEXT, "http://www.youtube.com/watch?v="+ id);
        mShareActionProvider.setShareIntent(sendIntent);
        popup.show();
    }
The XML configuration of the popupMenu looks like that:

Code:
    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
        <item
            android:id="@+id/share"
            android:title="@string/share"
            android:showAsAction="always"
            android:icon="@drawable/ic_action_share"
            android:actionProviderClass="android.widget.ShareActionProvider"/>
    </menu>
thanks for your help
 
Back
Top Bottom