首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

经过xml加载菜单Menus

2012-09-22 
通过xml加载菜单MenusMENU xmlns:androidhttp://schemas.android.com/apk/res/android?GROUP androi

通过xml加载菜单Menus

<MENU xmlns:android="http://schemas.android.com/apk/res/android">
?<GROUP android:id="@+id/myGroup">
??<ITEM android:id="@+id/New" android:title="New" android:orderInCategory="0"></ITEM>
??<ITEM android:id="@+id/Save" android:title="@string/save" android:orderInCategory="1" />
?</GROUP>
</MENU>

?

?/res/menu?? menus.xml?? android:orderInCategory="1"菜单的位置

@Overridepublic boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()) {case R.id.New:doSmth();break;case R.id.Save:doSmth();break;}return super.onOptionsItemSelected(item);}

?

Group Category tag

view sourceprint?1<GROUP android:id="@+id/some_group_id " android:menuCategory="secondary"> </GROUP>

Checkable Behavior tag
You can use it for group:

view sourceprint?1<GROUP android:id="@+id/noncheckable_group" android:checkableBehavior="none"></GROUP>

And also for menu item:

view sourceprint?1<ITEM android:id=".." android:title="…" android:checked="true" />

Submenu tag

view sourceprint?1<ITEM android:title="Submenu"> 2????<MENU> 3????????<ITEM… /> 4????</MENU> 5</ITEM>

Menu Icon tag

view sourceprint?1<ITEM android:id=".. " android:icon="@drawable/yourImageFile" />

Menu Enabling/Disabling tag

view sourceprint?1<ITEM android:id=".. " android:icon="@drawable/yourImageFile" android:enabled="true" />

Menu Item Shortcut tag

view sourceprint?1<ITEM android:id="… " android:alphabeticShortcut="n" />

Menu Visibility tag

view sourceprint?1<ITEM android:id="… " android:visible="true" />

?

热点排行