android EditText 使用
文本改变化要增加监听才能适时地返回文本数据,如代码,如果直接.getText().toString();是无法获得值的。
?
?
telNumText_send = (EditText) findViewById(R.id.telNumText_send);
??? ??? // 增加文本改变后监听
??? ??? telNumText_send.addTextChangedListener(new TextWatcher() {
??? ??????????? public void afterTextChanged(Editable s) {
??? ??????????????? // TODO Auto-generated method stub
??? ??????????? }
??? ??????????? public void beforeTextChanged(CharSequence s, int start, int count,
??? ??????????????????? int after) {
??? ??????????????? // TODO Auto-generated method stub
??? ??????????? }
??? ??????????? public void onTextChanged(CharSequence s, int start, int before,
??? ??????????????????? int count) {
??? ??????????????? // TODO Auto-generated method stub
??? ??????????????? // 得到电话
??? ?????????????? phone = telNumText_send.getText().toString();
??? ??????????? }
??? ???????????
??? ??????? });