您的位置:首页 > 其它

关于EditText的输入动态监听

2015-01-20 15:05 267 查看
关于对文本输入框 EditText的动态监听
直接贴上源码

//自己写一个 ChangableEditText类继承与实现文本监听
public class ChangableEditText extends AutoCompleteTextView implements TextWatcher{
public ChangableEditText(Context arg0, AttributeSet arg1) {
super(arg0, arg1);
// TODO Auto-generated constructor stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public 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,这样就可以用了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  method super 动态 public