问题描述
好吧,这是特定的一个pretty:我ShareActionProvider正在对在论坛帖子中。它的工作原理(除了讨厌Facebook的,但我明白这是一个众所周知的问题)。然而,当我选择从我的弹出菜单中的股票期权,两个列表绘制,一个在另一个之上。
Okay this is a pretty specific one: My ShareActionProvider is being used on posts in a forum. It works (apart from pesky facebook but I understand that is a well-known issue). However, when I select the share option from my pop-up menu, two lists are drawn, one on top of the other.
如何解决它,以便只显示一个列表?
How can I fix it so only one list is displayed?
编辑:
I使用ShareActionProvider在PopupMenu的,但显示两个PopupMenu的?
呼叫ShareActionProvider
Call ShareActionProvider from a PopupMenu
下面是我的code:
在XML菜单项
Here is my code:Menu item in xml
<item
android:id="@+id/menu_community_overflow_share"
android:title="@string/menu_share"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
android:orderInCategory="1"
app:showAsAction="never" />
Java的
private void share(MenuItem item) {
mShareActionProvider = (ShareActionProvider)MenuItemCompat.getActionProvider(item);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Here's a message originally posted by " + mClickedMessage.getFirstName()
+ " " + mClickedMessage.getLastName() + ": " + mClickedMessage.getTheMessage() + "\n\n");
sendIntent.setType("text/plain");
setShareIntent(sendIntent);
}
// Call to update the share intent
private void setShareIntent(Intent shareIntent) {
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(shareIntent);
}
}
和这里有一些图片:
第一次创建共享目录
And here are some images:Share list is first created
在查看所有点击
在列表滚动
希望这个问题是清楚的。还要注意的图标不能点击,但这样的行为就像在名单之外点击一起,杀死它。
Hopefully the problem is clear. Also note the icons cannot be clicked, doing so behaves like a click outside the list all together and kills it.
推荐答案
下面是code我最终会去(我什至不知道我是怎么计算出来,因为这是很久以前的事),但它可能会帮助别人。
Here is the code I eventually went with (I'm not even sure how I figured it out as it was a long time ago), but it might help someone.
该解决方案是不理想的,它消除了重复的名单,但离开枯燥的名单背后(无图标),我有种想其他的。如果我还记得共享这种方法已经过时,这将是优秀的,如果有人能够阐明这个问题更多的光。
The solution was not ideal, it removes the duplicate list, but leaves behind the boring list (without icons), and I kind of wanted the other one. If I recall this method of sharing is outdated and it would be excellent if someone could shed more light on the issue.
private void share(MenuItem item) {
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Here's a message originally posted by " + mClickedMessage.getFirstName()
+ " " + mClickedMessage.getLastName() + ": " + mClickedMessage.getTheMessage() + "\n\n Sent via Loylap");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_post_to)));
}
这篇关于Android的ShareActionProvider与弹出菜单 - 不希望重复列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!