@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.friends_list, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); mSearchView = (SearchView) menu.findItem(R.id.menuSearch).getActionView(); mSearchView.setSearchableInfo( searchManager.getSearchableInfo(getComponentName())); mSearchView.setOnQueryTextListener(new OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return true; } @Override public boolean onQueryTextChange(final String newText) { LensRocketLogger.i(TAG, "Text: " + newText); mCurrentName = newText; mBtnAddFriend.setEnabled(true); mBtnAddFriend.setVisibility(View.VISIBLE); mAdapter.getFilter().filter(newText, new FilterListener() { @Override public void onFilterComplete(int count) { if (mAdapter.getCount() > 0) mLvFriends.setVisibility(View.VISIBLE); else mLvFriends.setVisibility(View.GONE); if (!mCurrentName.equals("")) { mLayoutAddFriend.setVisibility(View.VISIBLE); } else { mLayoutAddFriend.setVisibility(View.GONE); } if (mLensRocketService.getLocalFriendNames().contains(newText)) mLayoutAddFriend.setVisibility(View.GONE); } }); mLblNewFriendName.setText(mCurrentName); return true; } }); return true; }