這裡就為大家整理一份出來
( 未完成 )
1 . addTextChangedListener
監聽文字被改變時
public class MainActivity extends Activity {
private String TAG = "EditTextSample";
private EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.editText1);
editText.addTextChangedListener(new TextWatcher(){
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
Log.d(TAG,"之前是 : " + s);
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Log.d(TAG,"文字被改變時 : " + s);
}
@Override
public void afterTextChanged(Editable s) {
Log.d(TAG,"之後為 : " + s);
}});
}
}
2 .
參考資料 : 來源1
沒有留言:
張貼留言