首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android EditText 应用

2012-06-26 
android EditText 使用文本改变化要增加监听才能适时地返回文本数据,如代码,如果直接.getText().toString(

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();
??? ??????????? }
??? ???????????
??? ??????? });

热点排行