Switch 开关按钮

switch_thumb.xml



    
        
            android:shape="oval">
            
            
            
        
    
switch_track.xml



    
        
            
            
            
        
    

    
        
            
            
            
        
    
boolean switch1 = SPUtil.getInstance().get(SPUtil.Key.SWITCH1, true);
getBinding().switch1.setChecked(switch1);
getBinding().switch1.setOnCheckedChangeListener((buttonView, isChecked) -> {
    mPresenter.setNoticeValve(isChecked);
    SPUtil.getInstance().put(SPUtil.Key.SWITCH1, isChecked);
});

 

你可能感兴趣的:(Android)