gpt4 book ai didi

android - 检查 EditText 是否具有特定字符

转载 作者:行者123 更新时间:2023-11-29 17:45:48 27 4
gpt4 key购买 nike

我搜索了一段时间,但找不到如何检查在 EditText 中键入的字符串中的特定字符?

最佳答案

通过使用 TextWatcher,您可以做到这一点。

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

关于android - 检查 EditText 是否具有特定字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26831163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com