开发者

What am i doing wrong here? Android context menu long click

I got my list view to respond to a long click. I override oncreatecontext menu

AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Intent facebookbrowserIntent = new Intent("android.intent.action.VIEW",
            Uri.pars开发者_如何学Pythone("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");

However this is not exactly what shows up. Sometimes other words (that shouldn't even) show up. None of the intents fire correctly. I've fiddled with group and order. Not sure exactly of what the sparse docs meant. Any help?


Take a closer look at the documentation for addIntentOptions. That method adds menu items. This means that when you do addIntentOptions it will create menu items. When you do add you'll create even more items. You don't need to do the menu.Add statements. This link is probably a good guide for what you're trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜