答案 0 :(得分:1)
试试这个
@Override
public void onPrepareOptionsMenu(Menu menu)
{
// Associate searchable configuration with the SearchView
SearchManager searchManager = (SearchManager)getActivity(). getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
{
@Override
public boolean onQueryTextSubmit(String query)
{
return false;
}
@Override
public boolean onQueryTextChange(String query)
{
// pass query to your filter
return true;
}
});
}