Ang*_*l R 5 android attributes kotlin
您好,我想知道如何从 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
    }
我已经试过了,但没有成功:
atleta_navbar.set(menu){menu=menuopt}
atleta_navbar.setTag(menuopt)
所以在 NavigationView 它将从这个开始:
对此:
在java中,你可以尝试在运行时重新膨胀NavigationView。
navigationView.getMenu().clear(); //clear old inflated items.
navigationView.inflateMenu(R.menu.new_navigation_drawer_items);
我不懂kotlin,但想法是一样的。
| 归档时间: | 
 | 
| 查看次数: | 830 次 | 
| 最近记录: |