zoukankan      html  css  js  c++  java
  • Edittext 的变化监听、图片设置

    edittext的变化监听有addTextChangedListener,code:

            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) {
                    if (s.length() > 5)
                        textView1.setText("大于 5");
                    else
                        textView1.setText("小于 5");
                }
            });
    

    也可以以接口的形式写入

    TextWatcher textWatcher;//定义一个watcher
    
    
     textWatcher = 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) {
                    if (s.length() > 5)
                        textView1.setText("大于 5");
                    else
                        textView1.setText("小于 5");
                }
            };
    
    
    
            editText.addTextChangedListener(textWatcher);
    

    动态对edittext的图片进行改变

            Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            editText.setCompoundDrawables(drawable, drawable, null, null); //四个参数代表四个位置,左上右下
    
  • 相关阅读:
    ios之单例模式
    ios之申请后台延时执行和做一个假后台的方法
    ios之gcd浅析
    ios之归档demo
    ios之快速领会VFL的demo
    ios之网络异常与正常视图的切换
    POJ 2280 Amphiphilic Carbon Molecules 极角排序 + 扫描线
    linux pthread
    directdraw显示yuv422(yuy2)
    nginx高效学习方法
  • 原文地址:https://www.cnblogs.com/lyxin/p/5872263.html
Copyright © 2011-2022 走看看