Switch in Navigation drawer item with Design Support Library on Android

前端 未结 8 1894
长情又很酷
长情又很酷 2020-12-30 07:05

I need to put Switch inside item in navigation drawer. I\'m using new design support library, but I cannot find if it is posibble at all. When using

android         


        
8条回答
  •  时光说笑
    2020-12-30 07:59

    For those of you using Kotlin Extensions

    1. Menu file
    
    
        
    
    
    
    1. Switch layout file
    
    
    1. Access in code
    nav_view.menu.findItem(R.id.nav_notifications_switch)
        .actionView
        .toggleSwitch
        .setOnCheckedChangeListener { _, isChecked ->
            
        }
    

提交回复
热议问题