什么是“节流”onQueryTextChange
的最佳方式,以便我的performSearch()
方法每秒只调用一次,而不是每次用户输入时调用?在SearchView中调节onQueryTextChange
public boolean onQueryTextChange(final String newText) {
if (newText.length() > 3) {
// throttle to call performSearch once every second
performSearch(nextText);
}
return false;
}
谢谢!不过,我现在并没有真正引入RxJava。它可以在本地完成吗? – aherrick
不幸的是,我不知道这个问题的任何常见清洁解决方案。我完全可以通过Handler延迟或Timer和TimerTasks来实现。 –