我的SearchView
操作栏中现在有一个它应该完全正常工作,无论如何我有一个问题,当我单击提交按钮时,即提交查询并显示结果,当我返回到我开始搜索的活动时从SearchView
扩展中,我的问题是如何关闭它,即在提交时将其图标化。这是我的代码。
searchView = (SearchView) item.getActionView();
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true);
searchView.setIconified(true);
searchView.setQueryRefinementEnabled(true);
searchView
.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
try {
searchView = (SearchView) item.getActionView();
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView.setSearchableInfo(searchManager
.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true);
searchView.setIconified(true);
searchView.setQueryRefinementEnabled(true);
searchView
.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
try {
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
}); // doesnot work
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
});