Android Actionbar items as three dots

<?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:id="@+id/menu_item_share"
        android:title="@string/share"
        android:icon="@android:drawable/ic_menu_share"
        app:showAsAction="ifRoom"
        android:actionProviderClass="android.widget.ShareActionProvider" />

    <item
        android:id="@+id/empty"
        android:title="@string/options"
        android:orderInCategory="101"
        app:showAsAction="always"
        android:icon="@drawable/baseline_more_vert_black">

        <menu>

            <item android:id="@+id/action_settings"
                android:icon="@android:drawable/ic_menu_preferences"
                app:showAsAction="ifRoom"
                android:title="@string/settings" />

            <item android:id="@+id/action_help"
                android:icon="@android:drawable/ic_menu_help"
                app:showAsAction="ifRoom"
                android:title="@string/help" />

        </menu>

    </item>

</menu>

You will need to add the baseline_more_vert_black icons to your res/drawable... folders once you've downloaded them from here.


try this;

menu.xml

<?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:id="@+id/menu_new_content_facebook"
        android:orderInCategory="100"
        android:title="@string/str_share_facebook"
        app:showAsAction="never" />

    <item
        android:id="@+id/menu_new_content_twitter"
        android:orderInCategory="200"
        android:title="@string/str_share_twitter"
        app:showAsAction="never" />
</menu>

MainActivity.java

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if(id == R.id.menu_new_content_twitter){
        // do something
    }
    return super.onOptionsItemSelected(item);
}