4.07Android使用Editview小技巧3

一、今日学习

 

5、通过监听OnFocusChangeListener判断EditText的焦点与否

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
private void initListener(){
    etDrugName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b){
                TypeUtils.getInstance( getActivity() ).hideKeyboardView();
            }
        }
    });
 
    etDrugNameOfInitial.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if (b){
                TypeUtils.getInstance( getActivity() ).hideKeyboardView();
            }
        }
    });
}

 

6、通过属性android:ellipsize来对文本内容的呈现做说明

1
android:ellipsize="end"

 

7、通过属性android:digits来规定只能输入的值

1
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 

二、问题

 暂无

三、明日计划

继续小技巧

posted @ 2021-04-07 22:00  居酿圆子  阅读(62)  评论(0编辑  收藏  举报