endian11
2020-09-24 83f2f00750381bbb6448908598c6e39aa080a100
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
51
52
53
package safeluck.drive.evaluation.fragment.rulefragments.cview;
 
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import safeluck.drive.evaluation.R;
 
/**
 * DriveJudge
 * Created by lzw on 2020/9/24. 10:25:00
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class TextCheckBox  extends LinearLayout {
 
    private CheckBox checkBox;
    public TextCheckBox(Context context) {
        this(context,null);
    }
 
    public TextCheckBox(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }
 
    public TextCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr,0);
    }
 
    public TextCheckBox(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView(context,attrs);
    }
 
    private void initView(Context context, AttributeSet attrs) {
        View view = LayoutInflater.from(context).inflate(R.layout.layout_text_checkbox,this,true);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TextCheckBox_attr_tvcheck);
        String string = typedArray.getString(R.styleable.TextCheckBox_attr_tvcheck_txt_des_check);
        boolean aBoolean = typedArray.getBoolean(R.styleable.TextCheckBox_attr_tvcheck_check_not, false);
 
        TextView text = view.findViewById(R.id.tv_checkbox);
        text.setText(string);
        checkBox = view.findViewById(R.id.check_setting);
 
        checkBox.setChecked(aBoolean);
    }
 
}