List of usage examples for android.widget SearchView setOnFocusChangeListener
public void setOnFocusChangeListener(OnFocusChangeListener l)
From source file:com.tweetlanes.android.core.view.BaseLaneActivity.java
void configureActionBarSearchView(Menu menu) { MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) searchItem.getActionView(); searchItem.setShowAsActionFlags(//w ww . jav a 2 s. c om MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchView.setOnQueryTextListener(this); OnFocusChangeListener onFocusChangeListener = new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { mCurrentComposeFragment.setIgnoreFocusChange(true); if (mComposeTweetView != null) { mComposeTweetView.setVisibility(View.GONE); } if (mComposeDirectMessageView != null) { mComposeDirectMessageView.setVisibility(View.GONE); } if (!hasFocus) { if (mCurrentComposeFragment == mComposeDirectMessageFragment) { if (mComposeDirectMessageView != null) { mComposeDirectMessageView.setVisibility(View.VISIBLE); } } else { if (mComposeTweetView != null) { mComposeTweetView.setVisibility(View.VISIBLE); } } } mCurrentComposeFragment.setIgnoreFocusChange(false); } }; searchView.setOnQueryTextFocusChangeListener(onFocusChangeListener); searchView.setOnFocusChangeListener(onFocusChangeListener); }