endian11
2020-12-04 8ee5db35d4b70cd13ca31d3783f427208aa8c0a4
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package safeluck.drive.evaluation.fragment.rulefragments.cview;
 
import android.content.Context;
import android.content.res.TypedArray;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
 
import safeluck.drive.evaluation.R;
 
/**
 * DriveJudge
 * Created by lzw on 2020/9/23. 15:10:43
 * 邮箱:632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class TextEditText extends LinearLayout {
 
    private TextView tv_des;
    private EditText editText;
 
    public TextEditText(Context context) {
        this(context,null);
 
    }
 
 
 
    public TextEditText(Context context, AttributeSet attrs) {
        this(context,attrs,0);
 
    }
 
    public TextEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr,0);
    }
 
    public TextEditText(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_viewgroup_tv_edit,this,true);
        int[] textEditText_attr = R.styleable.TextEditText_attr;
        TypedArray typedArray = context.obtainStyledAttributes(attrs, textEditText_attr);
        String des = typedArray.getString(R.styleable.TextEditText_attr_txt_des_tvedit);
        String input = typedArray.getString(R.styleable.TextEditText_attr_et_input);
        tv_des = view.findViewById(R.id.tv_des);
        editText = view.findViewById(R.id.et_value_setting);
 
        editText.setText(input);
 
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 
            }
 
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
 
            }
 
            @Override
            public void afterTextChanged(Editable s) {
 
            }
        });
        tv_des.setText(des);
    }
 
    public String getInput(){
        String edite = editText.getText().toString().trim();
        return edite;
    }
 
    public void setInput(String str){
        editText.setText(str.trim());
    }
}