Search code examples
androidactionbarsherlockshareactionprovider

How to have a Share option on ActionBarSherlock?


I included Share in my ActionBarSherlock using this:

LayoutInflater inflater = getLayoutInflater();
        final View view = inflater.inflate(R.layout.share,
                null, false);

menu.add("Share")
    .setIcon(R.drawable.ic_title_share_default)
    .setActionView(view1)
    .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM| MenuItem.SHOW_AS_ACTION_WITH_TEXT);

and share.xml is:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/share_action_provider"
        android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider"
        android:icon="@drawable/ic_title_share_default"
        android:showAsAction="ifRoom"
        android:title="Share"/>

</menu>

how can i get all the default option as drop down menu?. like bluetooth, messaging, facebook, linkedin etc and their default implementation?


Solution

  • If I'm not mistaken, you should put the options menu you don't want to appear as actions in the ActionBar as: android:showAsAction="never". Then, this automatically will force the overflow menu appear and your options displayed there.