/**
   * *********************************************************************************************
   */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setSubmitButtonEnabled(true);
    searchView.setQuery(searchText, true);
    searchView.setIconifiedByDefault(false);
    searchView.setQueryHint("Search Images ..");

    SearchView.OnQueryTextListener textChangeListener =
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextChange(String newText) {

            return true;
          }

          @Override
          public boolean onQueryTextSubmit(String queryValue) {
            searchText = queryValue;
            currentPage = 1;
            imageItemList.clear();
            imageItemAdapter.notifyDataSetChanged();
            refreshItems(currentPage);
            return true;
          }
        };
    searchView.setOnQueryTextListener(textChangeListener);
    return true;
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.setGroupVisible(R.id.sortGroup, true);
    menu.findItem(R.id.search).setVisible(true);

    SearchManager searchManager =
        (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchMenuItem = menu.findItem(R.id.search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextChange(String newText) {
            searchFilter(newText);
            return true;
          }

          @Override
          public boolean onQueryTextSubmit(String query) {
            InputMethodManager imm =
                (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
            return true;
          }
        });
    searchView.setOnFocusChangeListener(searchViewOnFocusChangeListener);
  }
Beispiel #3
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    if (fdroidApp.bluetoothAdapter == null) {
      // ignore on devices without Bluetooth
      MenuItem btItem = menu.findItem(R.id.action_bluetooth_apk);
      btItem.setVisible(false);
    }

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchMenuItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // LayoutParams.MATCH_PARENT does not work, use a big value instead
    searchView.setMaxWidth(1000000);
    searchView.setOnQueryTextListener(this);

    // If we were asked to execute a search before getting around to building the options
    // menu, then we should deal with that now that the options menu is all sorted out.
    if (pendingSearchQuery != null) {
      performSearch(pendingSearchQuery);
      pendingSearchQuery = null;
    }

    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.activity_recent_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.activity_recent_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    // searchView.setOnQueryTextListener(this);
    searchView.setQueryHint(getString(R.string.hint_search_activity_recent));
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    // Handle the query that user types in action bar search field
    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            Intent intent = new Intent(RecentActivity.this, SearchResultsActivity.class);
            intent.putExtra("query", query);
            startActivity(intent);
            return false;
          }

          @Override
          public boolean onQueryTextChange(String query) {
            return false;
          }
        });

    return super.onCreateOptionsMenu(menu);
  }
Beispiel #5
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {

            //                mNoteList = mDbHelper.queryName(query);
            //                mAdapter.notifyDataSetChanged();
            return false;
          }

          @Override
          public boolean onQueryTextChange(String newText) {

            if (TextUtils.isEmpty(newText)) {
              mNoteList = mDbHelper.queryAll();
            } else {
              mNoteList = mDbHelper.queryName(newText);
            }
            sortList(mNoteList);
            mAdapter.notifyDataSetChanged();
            return true;
          }
        });

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    /*getMenuInflater().inflate(R.menu.common_actionbar, _menu);

    this.menu = _menu;

    SearchManager manager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    menuSearch = menu.findItem(R.id.search);
    menuform = menu.findItem(R.id.survey_mi);

    final SearchView search = (SearchView) menu.findItem(R.id.search).getActionView();
    search.setQueryHint(Html.fromHtml("<font color = #FFFFFF>" + getResources().getString(R.string.search) + "</font>"));
    Log.d("bis", "pl info= " + manager.getSearchableInfo(getComponentName()).getSearchActivity());
    search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));

    search.setOnQueryTextListener(new OnQueryTextListener()
    {

        @Override
        public boolean onQueryTextChange(String query)
        {
            Log.d("bis", "sv query pl" + query);
            if (query.toString().length() < 1)
            {
                return true;
            }
            else
            {
                loadHistory(query);

                return true;
            }
        }

        @Override
        public boolean onQueryTextSubmit(String query)
        {
            // TODO Auto-generated method stub
            return false;
        }

    });


    return true;*/

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.common_actionbar, menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;
  }
Beispiel #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contactlist);

    mAppController = AppController.getInstance();
    mContext = this;

    tvHinweis = (TextView) findViewById(R.id.tvHinweis);

    Toolbar toolbar = (Toolbar) findViewById(R.id.activity_contacts_toolbar);
    if (toolbar != null) {
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayShowHomeEnabled(true);
      // getSupportActionBar().setSubtitle(null);
    }

    suggestions =
        new SearchRecentSuggestions(
            this, OrderSuggestionProvider.AUTHORITY, OrderSuggestionProvider.MODE);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchView = new SearchView(getSupportActionBar().getThemedContext());
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH); // Lupe anzeigen in der Tastatur
    // searchView.setSubmitButtonEnabled(true); //OK-Button anzeigen
    SearchView.SearchAutoComplete searchAutoComplete =
        (SearchView.SearchAutoComplete)
            searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);

    // Collapse the search menu when the user hits the back key
    searchAutoComplete.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {

          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) showSearch(false);
          }
        });

    try {
      // This sets the cursor resource ID to 0 or @null which will make it visible on white
      // background
      Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
      mCursorDrawableRes.setAccessible(true);
      mCursorDrawableRes.set(searchAutoComplete, 0);

    } catch (Exception e) {
    }

    checkServerConnection checkServerConnection = new checkServerConnection();
    checkServerConnection.execute("qw1");
  }
Beispiel #8
0
  @Override
  public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main_activity_options, menu);
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchItem = menu.findItem(R.id.menu_gosearch);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;
  }
Beispiel #9
0
 /** In der ActionBar die SearchView initialisieren */
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.fragment_wplist, menu);
   SearchManager searchManager =
       (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
   SearchView searchView =
       (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_List_search));
   searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
   searchView.setOnQueryTextListener(this);
   super.onCreateOptionsMenu(menu, inflater);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search_options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    return true;
  }
Beispiel #11
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    // Inflate menu to add items to action bar if it is present.
    inflater.inflate(R.menu.menu_main, menu);
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_buscar_sn_fragment, menu);
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

    if (mIsSearchResultView) {
      searchItem.setVisible(false);
    }

    // In version 3.0 and later, sets up and configures the ActionBar
    // SearchView
    if (Utils.hasHoneycomb()) {
      final SearchManager searchManager =
          (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
      searchView.setSearchableInfo(
          searchManager.getSearchableInfo(getActivity().getComponentName()));
      searchView.setOnQueryTextListener(
          new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String queryText) {

              if (alphabetAdapter != null) {
                alphabetAdapter.getFilter().filter(queryText);
              }
              return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {

              if (alphabetAdapter != null) {
                alphabetAdapter.getFilter().filter(newText);
              }
              return false;
            }
          });
      searchView.setOnCloseListener(
          new SearchView.OnCloseListener() {

            @Override
            public boolean onClose() {
              if (alphabetAdapter != null) {
                alphabetAdapter.getFilter().filter("");
              }
              return true;
            }
          });
    }
  }
Beispiel #13
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.item_search).getActionView();

    SearchableInfo info =
        searchManager.getSearchableInfo(new ComponentName(this, ResultActivity.class));
    searchView.setSearchableInfo(info);
    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_search, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    MenuItem searchMenuItem = menu.findItem(R.id.search);
    this.searchMenuItem = searchMenuItem;
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;
  }
Beispiel #16
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    MainActivity.menu = menu;

    final SearchView searchView =
        (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_consulta_tabela_preco, menu);

    SearchManager searchmanager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

    SearchView search = (SearchView) menu.findItem(R.id.ConsultaTabela).getActionView();

    search.setSearchableInfo(searchmanager.getSearchableInfo(this.getComponentName()));

    search.setQueryHint(getResources().getString(R.string.search_hint_Tabelapreco));

    return true;
  }
Beispiel #18
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.main_menu, menu);
   MenuItem searchItem = menu.findItem(R.id.action_search);
   if (searchItem != null) {
     SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
     if (searchView != null) {
       searchView.setOnQueryTextListener(this);
       SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
       searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
     }
   }
   return true;
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView mSearchView = (SearchView) menu.findItem(R.id.search_view).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconifiedByDefault(true);

    return true;
  }
Beispiel #20
0
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_search, menu);

    //        SearchView searchView =
    //                (SearchView) menu.findItem(R.id.action_search).getActionView();

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setFocusable(true);
    searchView.setQueryHint(getString(R.string.action_search_queryHint));
    searchView.onActionViewExpanded();

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (null != searchView) {
      searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
      searchView.setIconifiedByDefault(false);
      searchView.setFocusable(true);
    }

    SearchView.OnQueryTextListener queryTextListener =
        new SearchView.OnQueryTextListener() {
          public boolean onQueryTextChange(String newText) {
            // this is your adapter that will be filtered
            return true;
          }

          public boolean onQueryTextSubmit(String query) {
            // Here u can get the value "query" which is entered in the search box.
            String urlEncodedQuery = query.trim();
            try {
              urlEncodedQuery = URLEncoder.encode(query, "UTF-8");
            } catch (IOException e) {
              e.printStackTrace();
            }
            Log.i(LOG_TAG, "URL Encoded query : " + urlEncodedQuery);
            Intent intent = new Intent(getApplicationContext(), CardListActivity.class);
            intent.putExtra(
                CardListActivity.INTENT_EXTRA_LAUNCHER, CardListActivity.LAUNCHER_SEARCH);
            intent.putExtra(CardListActivity.INTENT_EXTRA_SEARCH_QUERY, urlEncodedQuery);
            intent.putExtra(CardListActivity.INTENT_EXTRA_TITLE, query);
            startActivity(intent);
            return true;
          }
        };
    searchView.setOnQueryTextListener(queryTextListener);

    return true;
  }
Beispiel #21
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.map_actions, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    android.support.v7.widget.SearchView searchView =
        (android.support.v7.widget.SearchView) menu.findItem(R.id.action_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the options menu from XML
    getMenuInflater().inflate(R.menu.note_list, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_notes).getActionView();

    // Current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);

    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(this);
    searchView.setOnCloseListener(this);
    searchView.setOnSearchClickListener(this);
    return true;
  }
Beispiel #24
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_listado_tabs, menu);

    SearchManager SManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
    mSearchView.setSearchableInfo(SManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconifiedByDefault(false);
    mSearchView.setQueryHint("Search...");
    mSearchView.setOnQueryTextListener(this);

    return super.onCreateOptionsMenu(menu);
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.search_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.search_action_search_view).getActionView();
    // Assumes current activity is the searchable activity
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconifiedByDefault(false);
    mSearchView.setOnQueryTextListener(this);

    // TODO: Bug with searchView and request focus. Keyboard not showing up.

    return true;
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.search_orders_options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconified(false);
    searchView.setIconifiedByDefault(false);
    searchView.setClickable(true);
    searchView.setOnQueryTextListener(this);
    searchView.setOnClickListener(this);
    moveSearchIconFromBeginToEnd(searchView);

    return true;
  }
Beispiel #27
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    // Inflate menu to add items to action bar if it is present.
    inflater.inflate(R.menu.menu_main, menu);

    SharedPreferences settings = getSharedPreferences("settings", 0);

    boolean isCheckedCircle = settings.getBoolean("circle", false);
    MenuItem item = menu.findItem(R.id.circle);
    item.setChecked(isCheckedCircle);

    // Associate searchable confirguration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            adapter.setTracks(musicSrv.searchResults(query));
            adapter.notifyDataSetChanged();
            return false;
          }

          @Override
          public boolean onQueryTextChange(String newText) {
            return false;
          }
        });
    searchView.setOnCloseListener(
        new SearchView.OnCloseListener() {
          @Override
          public boolean onClose() {
            adapter.setTracks(musicSrv.all_songs);
            musicSrv.setCurrentList(musicSrv.all_songs);
            adapter.notifyDataSetChanged();
            return false;
          }
        });

    return true;
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   if (!mNavigationDrawerFragment.isDrawerOpen()) {
     // Only show items in the action bar relevant to this screen
     // if the drawer is not showing. Otherwise, let the drawer
     // decide what to show in the action bar.
     getMenuInflater().inflate(R.menu.main, menu);
     MenuItem searchItem = menu.findItem(R.id.action_search);
     searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
     searchView.setQueryHint("두 자 이상 입력하세요");
     searchView.setOnQueryTextListener(queryTextListener);
     SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
     if (null != searchManager) {
       searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
     }
     // 검색필드를 항상 표시하고싶을 경우false, 아이콘으로 보이고 싶을 경우 true
     searchView.setIconifiedByDefault(true);
     restoreActionBar();
     return true;
   }
   return super.onCreateOptionsMenu(menu);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_ads_list, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);

    searchView.setIconifiedByDefault(false);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            return false;
          }

          @Override
          public boolean onQueryTextChange(String query) {

            final ArrayList<AdsItem> filteredAdsList;
            filteredAdsList = searchFilter(mAdsList, query);

            if (filteredAdsList.size() > 0) {
              mAdsListRecycler.setVisibility(View.VISIBLE);
              mEmptySearch.setVisibility(View.GONE);
            } else {
              mAdsListRecycler.setVisibility(View.GONE);
              mEmptySearch.setVisibility(View.VISIBLE);
            }
            mAdapter.animateTo(filteredAdsList);
            mAdsListRecycler.scrollToPosition(0);
            return true;
          }
        });
    return true;
  }
Beispiel #30
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    MenuItem search = menu.findItem(R.id.action_search);

    SearchManager searchManager =
        (SearchManager) MainActivity.this.getSystemService(SEARCH_SERVICE);
    SearchView searchView = null;

    if (search != null) {
      searchView = (SearchView) search.getActionView();
    }
    if (searchView != null) {
      searchView.setSearchableInfo(
          searchManager.getSearchableInfo(MainActivity.this.getComponentName()));
      searchView.setOnQueryTextListener(
          new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String q) {
              // TODO: Open the team activity directly
              query = q;
              filter(query);
              adapter.notifyDataSetChanged();
              return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
              query = newText;
              filter(query);
              adapter.notifyDataSetChanged();
              return false;
            }
          });
    }

    return true;
  }