MaterialButtonToggleGroup 做底部导航栏和FragmentContainerView联动

nice~




    


        

            

            

            

            

            
        




    
    
    
    

        mInflate.bottom.addOnButtonCheckedListener((group, checkedId, isChecked) -> {

            if(isChecked && defalutCheckId!=checkedId) {
                Log.i(TAG, "initListener: ---------xxxx");
                if(checkedId==R.id.btn_add){
                    Log.i(TAG, "initListener: --------弹出框");

                }else{
                    mNavController.navigate(checkedId);
                }

                group.findViewById(defalutCheckId).setSelected(false);
                group.findViewById(checkedId).setSelected(true);
                defalutCheckId = checkedId;
            }

        });
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.fcv_fragment);
mNavController = navHostFragment.getNavController();

defalutCheckId=R.id.btn_main;

你可能感兴趣的:(android,android,studio,ide)