zhangzengfei
2022-01-10 4496b59ab27d569df1da7ef634e02273b3a9618a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.basic.security.widget;
 
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.FrameLayout;
 
import com.basic.security.R;
 
public class CheckBoxView extends FrameLayout {
 
    Object bean;
 
    public CheckBoxView(Context context, Object bean) {
        super(context);
        this.bean = bean;
        initView();
 
    }
 
    public CheckBoxView(Context context) {
        super(context);
        initView();
    }
 
    public CheckBoxView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }
 
    public CheckBoxView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
    }
 
    private void initView() {
        View view = inflate(getContext(), R.layout.checkbox_view, null);
        CheckBox cb = view.findViewById(R.id.checkbox);
        cb.setText(bean + "");
        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            }
        });
        addView(view);
    }
 
}