Created
May 28, 2015 10:30
-
-
Save yishai-glide/1f9496950d2fbeb8f1ec to your computer and use it in GitHub Desktop.
toolbar searchview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void configureSearchView(Menu menu) { | |
MenuItem searchItem = menu.findItem(R.id.action_search); | |
searchViewAction = (SearchView) MenuItemCompat.getActionView(searchItem); | |
searchViewAction.setOnQueryTextListener(this); | |
searchViewAction.setOnCloseListener(this); | |
searchViewAction.setSubmitButtonEnabled(false); | |
searchViewAction.setIconifiedByDefault(true); | |
EditText editText = (EditText) searchViewAction.findViewById(android.support.v7.appcompat.R.id.search_src_text); | |
editText.addTextChangedListener(new TextWatcher() { | |
@Override | |
public void onTextChanged(CharSequence s, int start, int before, int count) {/** empty method **/} | |
@Override | |
public void beforeTextChanged(CharSequence s, int start, int count,int after) {/** empty method **/} | |
@Override | |
public void afterTextChanged(Editable s) { | |
mAdapter.getFilter().filter(s); | |
} | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment