return null;
}
}
};
editText.setFilters(new InputFilter[]{filter});
}
3.给自定义view对外提供一个获取值的方法
public String getText() {
return edittext.getText().toString();
}
1.MyEditVIew.java
public class MyEditVIew extends RelativeLayout {
private TextView textview;
private EditText edittext;
private boolean mtextisshow; //文字是否显示判断
private boolean imgisshow; //图片是否显示判断
private String hintText;
private ImageView imageView;
private ImageView iV_clean;
public MyEditVIew(Context context) {
super(context,null);
}
public MyEditVIew(Context context, AttributeSet attrs) {
super(context, attrs,0);
init(context, attrs);
setEditTextInputSpace(edittext);
textAddChanged();
imageOnClick();
}
public MyEditVIew(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
//打气布局,获取自定义属性的值
private void init(Context context, AttributeSet attrs) {
LayoutInflater.from(context).inflate(R.layout.my_edit_view, this);
textview = findViewById(R.id.textview);
edittext = findViewById(R.id.edittext);
imageView = findViewById(R.id.imageView);
iV_clean=findViewById(R.id.iV_clean);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MyEditVIew);
hintText = ta.getString(R.styleable.MyEditVIew_myhintText);
}
//文字输入监听以及一些逻辑处理(未优化)
private void textAddChanged(){
edittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count