Android的菜单组可勾选 [英] Android Menu Group Checkable

查看:649
本文介绍了Android的菜单组可勾选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前编程API为10以上。我创建了一个菜单,并正在寻求实现该方法Menu.setGroupCheckable(ID,可检查的,独占)。下面是我的code。从文档我期待在所选项目的复选标记出组和禁用其他的。然而,这种情况并非如此。

I currently am programming for API 10 and above. I created a menu and was looking to implement the method Menu.setGroupCheckable(id, checkable, exclusive). Below is my code. From the documentation I was expecting a check mark over the selected item out of the group and the other ones to be disabled. However, this is not the case.

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
     super.onCreateOptionsMenu(menu);
     menu.add(0, 1, 0, "I1").setIcon(R.drawable.ic_launcher);
     menu.add(0, 2, 1, "I2");
     menu.add(0,3,2,"I3");

     menu.add(1, 4, 3, "I4");
     menu.add(1, 5, 4, "I5");
     menu.add(1,6,5,"I6");

    menu.setGroupCheckable(1, true, true);

     return true;
}


Android文档链接: http://developer.android.com/reference/安卓/浏览/ Menu.html

推荐答案

<一个href=\"http://stackoverflow.com/questions/6698954/android-menu-two-single-checkable-groups-in-the-same-menu\">Android菜单:在同一菜单中两个单可检查组

http://www.brighthub.com/mobile/google-安卓/用品/ 28673.aspx

HTTP:// WWW。 MYSAMPLE code.com / 2011/07 / Android的选项菜单,子菜单,group.html

<一个href=\"http://www.itcsolutions.eu/2011/09/26/android-tutorial-how-to-add-a-menu-programmatic-vs-declarative-solution/\" rel=\"nofollow\">http://www.itcsolutions.eu/2011/09/26/android-tutorial-how-to-add-a-menu-programmatic-vs-declarative-solution/

这些链接可以帮助你!

这篇关于Android的菜单组可勾选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆