如何最好地“节流”onQueryTextChange
,使得我的performSearch()
方法只在用户输入之后的每秒调用一次而不是每次用户键入时都调用?
public boolean onQueryTextChange(final String newText) {
if (newText.length() > 3) {
// throttle to call performSearch once every second
performSearch(nextText);
}
return false;
}