如何处理左箭头点击? 我通过意图进行了搜索,没关系:
@Override
protected void onNewIntent(Intent intent) {
handleIntent(intent);
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
mFilter = intent.getStringExtra(SearchManager.QUERY);
...search query
}
}
和我的关闭按钮代码:
ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
closeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
...
}
如何处理左箭头?
答案 0 :(得分:0)
SearchView小部件中有OnCloseListener
。
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
...
});
答案 1 :(得分:0)
// When using the support library, the setOnActionExpandListener() method is
// static and accepts the MenuItem object as an argument
MenuItemCompat.setOnActionExpandListener(menuItem, new OnActionExpandListener() {
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
// Do something when collapsed
return true; // Return true to collapse action view
}
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
// Do something when expanded
return true; // Return true to expand action view
}
});