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); //四个参数代表四个位置,左上右下
    
  • 相关阅读:
    win7下cygwin命令行颜色和中文乱码解决
    maven mirror
    maven命令
    dubbo获取错误ip
    eclipse netbeans 代码模板
    windows下配置Groovy
    c++ 载入内存中dll ,以及内存注入
    表达式求值的 计算器
    vc 编译器的一些精典报错
    内联汇编实现 memcpy 和 memset
  • 原文地址:https://www.cnblogs.com/lyxin/p/5872263.html
Copyright © 2011-2022 走看看