gpt4 book ai didi

android - 我在这里做错了什么? Android上下文菜单长按

转载 作者:行者123 更新时间:2023-11-30 04:39:08 25 4
gpt4 key购买 nike

我的 ListView 可以响应长按。我覆盖 oncreatecontext 菜单

AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Intent facebookbrowserIntent = new Intent("android.intent.action.VIEW",
Uri.parse("http://www.facebook.com/sharer.php?u=http://autobotcentral.info/sd/&t=the_title"));
Intent twitterbrowserIntent = new Intent("android.intent.action.VIEW",
Uri.parse("http://twitter.com/?status=the_title"));
menu.setHeaderTitle(mStrings.get(info.position).CleanName);

Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setData(Uri.parse("sms:"));
sendIntent.putExtra("sms_body", mStrings.get(info.position).CleanName );

output.setText(mStrings.get(info.position).CleanName);

menu.addIntentOptions(Menu.NONE, 0, 0,
this.getComponentName(),null, facebookbrowserIntent, 0, null);

menu.addIntentOptions(Menu.NONE, 0, 1,
this.getComponentName(),null, sendIntent, 0, null);
menu.addIntentOptions( Menu.NONE, 0, 2,
this.getComponentName(),null, twitterbrowserIntent, 0, null);

menu.add(Menu.NONE, 0, 0, "Facebook Entry");
menu.add(Menu.NONE, 0, 1, "Sms to friend");
menu.add(Menu.NONE, 0, 2, "Twitter Entry");

然而,事实并非如此。有时会出现其他词(甚至不应该)。没有一个 Intent 正确触发。我摆弄了组和顺序。不确定稀疏文档的确切含义。有帮助吗?

最佳答案

仔细看看 documentation对于 addIntentOptions。该方法添加菜单项。这意味着当您执行 addIntentOptions 时,它将创建菜单项。当您执行 add 时,您将创建更多项目。您不需要执行 menu.Add 语句。这link可能是您尝试执行操作的良好指南。

关于android - 我在这里做错了什么? Android上下文菜单长按,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6313142/

25 4 0