检查是否具有的EditText特定的字符 [英] Check if EditText has specific character
本文介绍了检查是否具有的EditText特定的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索了一会儿,但找不到如何检查字符串中的特定字符在一个EditText类型?
I searched a while but could not find how to check for a specific character in a string that was typed in an EditText?
推荐答案
通过使用TextWatcher,可以实现左右。
By using TextWatcher, you can achieve so.
editText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
Log.i(TAG, "specific character = " + s.charAt(count-1));
}
});
这篇关于检查是否具有的EditText特定的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文