gpt4 book ai didi

android - TextView 中的 OnWrite

转载 作者:行者123 更新时间:2023-11-29 22:13:14 25 4
gpt4 key购买 nike

我有一个 TextView,我想控制用户何时插入字母。

Ex.

s -> search s in database and show results
st -> search st in database and show results
sta -> search sta in database and show results
stac -> search stac in database and show results
stack -> search stack in database and show results
...
...
...

我该怎么做?

最佳答案

用户 TextWatcher当用户在 EditText 中输入任何文本时获取文本

searchText.addTextChangedListener(new TextWatcher() {

public void afterTextChanged(Editable s) {

String text = searchText.getText().toString();
if (text != null && text.length() > 0) {
// Call your method that will get Data from Database and then update then data to the ListView or anything you want
getSearchDataFromDBagianUserText(text);
}

}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}

public void onTextChanged(CharSequence s, int start, int before, int count) {

}
});

关于android - TextView 中的 OnWrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9101764/

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