每次用户在Edittext中编写单个charachter时,是否可以更新String?我想做一种实时搜索。
答案 0 :(得分:2)
是的,使用addTextChangedListener()
添加TextWatcher
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
yourString = s.toString();
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void afterTextChanged(Editable s) { }
});