Throttle onQueryTextChange in SearchView
问题 What's the best way to "throttle" onQueryTextChange so that my performSearch() method is called only once every second instead of every time the user types? public boolean onQueryTextChange(final String newText) { if (newText.length() > 3) { // throttle to call performSearch once every second performSearch(nextText); } return false; } 回答1: Building on aherrick's code, I have a better solution. Instead of using a boolean 'canRun', declare a runnable variable and clear the callback queue on the