+
+ onCreateSetupActionBar();
+ }
+
+ private void onCreateSetupActionBar() {
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayShowTitleEnabled(false);
+
+ filterSearchView = new SearchView(getSupportActionBar().getThemedContext());
+ filterSearchView.setIconifiedByDefault(false);
+ // filterSearchView.setIconified(false); // puts the magnifying glass in the
+ // wrong place.
+ filterSearchView.setQueryHint(getString(R.string.searchText));
+ filterSearchView.setSubmitButtonEnabled(false);
+ final int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300,
+ getResources().getDisplayMetrics());
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(width,
+ FrameLayout.LayoutParams.WRAP_CONTENT);
+ filterSearchView.setLayoutParams(lp);
+ filterSearchView.setImeOptions(
+ EditorInfo.IME_ACTION_SEARCH |
+ EditorInfo.IME_FLAG_NO_EXTRACT_UI |
+ EditorInfo.IME_FLAG_NO_ENTER_ACTION |
+ // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API
+ // 11
+ EditorInfo.IME_MASK_ACTION |
+ EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
+
+ filterSearchView.setOnQueryTextListener(new OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ return true;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String filterText) {
+ setListAdapater();
+ return true;
+ }
+ });
+ filterSearchView.setFocusable(true);
+
+ actionBar.setCustomView(filterSearchView);
+ actionBar.setDisplayShowCustomEnabled(true);