关于EditText动态监听

来源:互联网 发布:古玩市场淘宝视频 编辑:程序博客网 时间:2024/06/04 17:53

//自己写一个 ChangableEditText类继承与实现文本监听

public class ChangableEditText extends AutoCompleteTextView implements TextWatcher{public ChangableEditText(Context arg0, AttributeSet arg1) {super(arg0, arg1);// TODO Auto-generated constructor stub}@Overridepublic void afterTextChanged(Editable arg0) {// TODO Auto-generated method stub}@Overridepublic void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {// TODO Auto-generated method stub}@Overridepublic void onTextChanged(CharSequence text, int start, int before,int after) {Log.v("result", text + "");}}


//接下来看布局

//布局很简单就是一个EditText的改变

//注意一定要带上包名,否则会出错

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical" >    <com.example.testdialog.ChangableEditText        android:id="@+id/editText1"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:ems="10" >        <requestFocus />    </com.example.testdialog.ChangableEditText></LinearLayout>


OK,这样就可以用了


本文出自 “爬过山见过海” 博客,请务必保留此出处http://670176656.blog.51cto.com/4500575/1606145

0 0
原创粉丝点击