zoukankan      html  css  js  c++  java
  • Android应用开发EditText文本内容变化监听方法

    1. import android.app.Activity;  
    2. import android.os.Bundle;  
    3. import android.text.Editable;  
    4. import android.text.TextWatcher;  
    5. import android.widget.EditText;  
    6.   
    7. public class ActMain extends Activity {  
    8.   
    9. private EditText et_search;  
    10.   
    11. @Override  
    12. public void onCreate(Bundle savedInstanceState) {  
    13. super.onCreate(savedInstanceState);  
    14. setContentView(R.layout.main);  
    15.   
    16. et_search = (EditText) findViewById(R.id.et_search);  
    17.   
    18. et_search.addTextChangedListener(textWatcher);  
    19. }  
    20.   
    21. private TextWatcher textWatcher = new TextWatcher() {  
    22.   
    23. @Override  
    24. public void onTextChanged(CharSequence s, int start, int before,  
    25. int count) {  
    26. //    
    27. System.out.println("-1-onTextChanged-->"  
    28. + et_search.getText().toString() + "<--");  
    29. }  
    30.   
    31. @Override  
    32. public void beforeTextChanged(CharSequence s, int start, int count,  
    33. int after) {  
    34. //    
    35. System.out.println("-2-beforeTextChanged-->"  
    36. + et_search.getText().toString() + "<--");  
    37.   
    38. }  
    39.   
    40. @Override  
    41. public void afterTextChanged(Editable s) {  
    42. //    
    43. System.out.println("-3-afterTextChanged-->"  
    44. + et_search.getText().toString() + "<--");  
    45.   
    46. }  
    47. };  
  • 相关阅读:
    IOS 沙盒机制 浅析
    IOS CALayer(二)
    IOS CALayer(一)
    IOS 二维码扫描
    IOS 二维码生成
    UIView属性
    JSON 与 XML 的比较
    Xcode 中 pch 文件配置
    Error:linker command failed with exit code 1 (use -v to see invocation)
    开发常用宏
  • 原文地址:https://www.cnblogs.com/1995hxt/p/4829180.html
Copyright © 2011-2022 走看看