java - Android 以编程方式从 Res/menu 获取菜单
问题描述
我正在使用 LinearLayout 创建自定义底部导航。我想Menu
用作物品。
<com.sam.grocerystore.views.XBottomNavigation
android:id="@+id/customBottomNav"
android:layout_width="match_parent"
android:layout_height="55dp"/>
在 Java 中
XBottomNavigation xNav = new XBottomNavigation(this);
xNav.inflateMenu(R.menu.bottom_nav_menu);
在 XBottomNavigation 中
public void inflateMenu(@MenuRes int menuRes){
Menu menu = getMenuFromResID(menuRes);
}
有人可以帮我创造getMenuFromResID
功能吗?
解决方案
推荐阅读
- javascript - (节点:1572)UnhandledPromiseRejectionWarning:ValidationError:配置文件验证失败:education.0.fieldsofstudy:需要路径“fieldsofstudy”
- php - Zend 3 - 使用记录器作为服务
- php - 添加两个多维数组并将它们的所有项目添加到另一个数组中
- magento2 - 产品不显示在分类页面 Elastic search
- java - 自动装配依赖异常,
- javascript - 如何在下拉菜单下创建下拉菜单
- rust - 使用 kcov 的 Rust 覆盖似乎不正确
- javascript - jQuery 不会从 getJSON 方法追加新元素
- python - Pygame - 在两点之间移动矩形
- angular - 如何从Angular 4的循环中等待并获得每个HttpClient服务调用的响应