我试图在Android中创建一个支付方法活动。
我见过很多网站动态识别我的文字输入(信用卡号码),所以如果我输入前3~4位数字,它就知道这张卡是否是VISA,主人等等。在我打字之前。
我想要做的是每次用户输入时更新从getText()方法获得的字符串值。但我不知道该从哪里开始!
发布于 2014-05-30 07:59:25
您可以将侦听器附加到EditText,然后重写您感兴趣的自定义操作方法。下面是一个例子,你可以这样做。http://www.mysamplecode.com/2012/06/android-edittext-text-change-listener.html
祝好运
发布于 2014-05-30 07:58:51
您可以在文本更改时向EditText附加一个被通知的侦听器,这是安卓框架本机支持的:例如:
editText = (EditText)findViewById(R.id.your_edit_text_id);
textMessage.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
//perform checks or implement logic on what the user has entered so far here...
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count){}
}); https://stackoverflow.com/questions/23949628
复制相似问题