操作栏中的Android分享按钮无需滚动

时间:2015-01-02 18:20:52

标签: android android-actionbar android-actionbaractivity

我在操作菜单中有共享按钮,但是当我点击“全部显示”时,菜单已打开,我无法滚动列表。为什么呢?

代码:

public boolean onCreateOptionsMenu(Menu menu) {

     getMenuInflater().inflate(R.menu.main, menu);
        mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share)
                .getActionProvider();
        mShareActionProvider.setShareIntent(doShare());

        return super.onCreateOptionsMenu(menu);
    }
 public Intent doShare() {
            // populate the share intent with data
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT, "Google play Link");
            return intent;
        }

main.xml:

<?xml version="1.0" encoding="utf-8"?>

    <item
        android:id="@+id/menu_share"
        android:icon="@drawable/share"
         android:showAsAction="always"
        android:title="Share"
        android:actionProviderClass=
            "android.widget.ShareActionProvider" />

0 个答案:

没有答案