To put it bluntly, we will introduce the main functions of the code I wrote: This menu program can be used only by configuring XML, and one or more permissions can be set for each menu item during configuration, easy to use. You can download it as soon as possible. I uploaded it to my resources.
Code Overview:
XML file:
<? XML version = "1.0" encoding = "gb2312"?>
<Menuconfig>
<Displayers>
<Displayer name = "listmenu" type = "wp.com"/>
</Displayers>
<! -- Roles indicates user permissions. Multiple permissions are separated by commas. -->
<Menus>
<Menu name = "yonghuguanli" Title = "user management">
<Item name = "zjyh" target = "Main" Title = "Add User 1" location = "AA" roles = "mm"/>
<Item name = "scyh" target = "Main" Title = "delete user 2" location = "BB" roles = "XX, DD"/>
<Item name = "zjyh" target = "Main" Title = "Add User 3" location = "AA" roles = "XX"/>
<Item name = "scyh" target = "Main" Title = "delete user 4" location = "BB" roles = "XX, cc"/>
</Menu>
<Menu name = "shebeiguanli" Title = "device management">
<Item name = "zjsb" target = "Main" Title = "add a device" location = "#" roles = "cc"/>
<Item name = "scsb" target = "Main" Title = "delete a device" location = "#" roles = "XX"/>
</Menu>
....................
..........................
For example, if user A has the DD and CC permissions, only two corresponding menus are displayed.
If the user does not have the permission to include sub-menus, the total menu is not displayed.
Call method:
......
Creatmenu CM = new creatmenu ();
String source = cm. readdom ("DD, cc"); // User Permissions
.......
Menu image style: