android读取menu资源,Android-res:menu资源文件(Menu Resource)

Android-res/menu资源文件(Menu Resource)

概念介绍

For all menu types, Android provides a standard XML format to define menu items. Instead of building a menu in your activity’s code, you should define a menu and all its items in an XML menu resource. You can then inflate the menu resource (load it as a Menu object) in your activity or fragment.

对于所有菜单类型,Android 提供了标准的 XML 格式来定义菜单项。您应在 XML 菜单资源中定义菜单及其所有项,而不是在 Activity 的代码中构建菜单。定义后,您可以在 Activity 或片段中扩充菜单资源(将其作为 Menu 对象加载)。

Using a menu resource is a good practice for a few reasons:

通过menu resource来创建menu,有以下好处:

It’s easier to visualize the menu structure in XML.

更易于使用 XML 可视化菜单结构

It separates the content for the menu from your application’s behavioral code.

将菜单内容与应用的行为代码分离

It allows you to create alternative menu configurations for different platform versions, screen sizes, and other configurations by leveraging the app resources framework.

允许您利用应用资源框架,为不同的平台版本、屏幕尺寸和其他配置创建备用菜单配置

表单使用介绍

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值