Select only one checkbox

I made this:

public void check_checkbox(){

    int CB_count=0;
    if (CB_1.isChecked()) {
        CB_count=CB_count+1;
    }if (CB_2.isChecked()) {
        CB_count=CB_count+1;
    }if (CB_3.isChecked()) {
            CB_count=CB_count+1;}

        if (CB_count == 1) {

            //do your magic

        } else {
            Toast.makeText(getActivity(), "you only can select 1 checkbox", Toast.LENGTH_SHORT).show();
        }
}

I improve it, on the onCreateView=

CB_1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    CB_2.setChecked(false);
                    CB_3.setChecked(false);
                }
            }
        });
        CB_2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    CB_1.setChecked(false);
                    CB_3.setChecked(false);
                }
            }
        });
        CB_3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    CB_2.setChecked(false);
                    CB_1.setChecked(false);
                }
            }
        });

Why don't you use Radio Buttons instead? They are meant exactly for that.

But if you insist on using check boxes, modify the event of on select of any check box such that when it is selected it disables the other check boxes.