搜索查看onMenuItemActionCollapse不工作 [英] SearchView onMenuItemActionCollapse Not Working
本文介绍了搜索查看onMenuItemActionCollapse不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用搜索查看
,而我的活动extanding 福尔摩斯库。
I'm using SearchView
while my activity is extanding Sherlock Library.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
inflater.inflate(R.menu.countriesxml, menu);
SearchView mSearchView = (SearchView) menu.findItem(R.id.searchall)
.getActionView();
mSearchView.setQueryHint("Search for smartphones");
MenuItem menuItem = menu.findItem(R.id.searchall);
menuItem.setOnActionExpandListener(new OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return false;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// TODO Auto-generated method stub
item.collapseActionView();
indicator.setVisibility(View.VISIBLE);
pager.setVisibility(View.VISIBLE);
lvth.setVisibility(View.GONE);
return true;
}
});
return;
}
请注意,我试图用OnCloseListener(),但没有奏效。
Please note that i tried to use OnCloseListener() but it didn't work.
怎么了?
推荐答案
看一下您的code。在本节:
have a look at your code at this section:
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return false;
}
低于code替换它,然后再试一次。
Replace it with below code and try again.
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
这篇关于搜索查看onMenuItemActionCollapse不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文