相关疑难解决方法(0)

如何以编程方式更改 NavigationView 的菜单?

您好,我想知道如何从 NavigationView 更改菜单 ID,在这种情况下,它是在用户单击 RadioButton 时触发的。我已经有了那部分,但我只需要知道如何更改菜单,因此在菜单中,单击 RadioButton 时它将显示不同的选项。

private var radioAdm:RadioButton? = null
private var radioAtle:RadioButton? = null
private var atletanav:BottomNavigationView? = null
private var menuopt = "@menu/admin_menu"

override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
     // Here is where I need to put that code
    }
Run Code Online (Sandbox Code Playgroud)

我已经试过了,但没有成功:

atleta_navbar.set(menu){menu=menuopt}
atleta_navbar.setTag(menuopt)
Run Code Online (Sandbox Code Playgroud)

所以在 NavigationView 它将从这个开始:

在此处输入图片说明

对此:

在此处输入图片说明

android attributes kotlin

5
推荐指数
1
解决办法
830
查看次数

标签 统计

android ×1

attributes ×1

kotlin ×1