android - How to search only in several fragments from ActionBar? -


Recently I've added a tool to search inside the pieces. Some pieces have a list view, so when a user If a search typed the text, then a list view filtered rows. After this, it is done with the ActionBar.

I have added listeners to several main activities, so when a user writes a text at the top of the screen, it filters rows into one piece. But there is no need to find anything in other pieces, so a magnifying glass is hidden.

However, Talac is drawn on each screen . . I did not even try to show it in the activity and only attracted only one piece with this code: @Orreide Public Zero Copyright menu (Menu menu, Inflatable inflater) {inflater. Inflate (R. menu menu_invitro, menu); Menu.clear (); // SearchView SearchView searchView = (SearchView) menu.findItem (R.id.action_search) with associate searchable configuration .getActionView (); SearchManager searchManager = (SearchManager) getActivity (). GetSystemService (Reference.Search_SERVICE); SearchView.setSearchableInfo (searchManager.getSearchableInfo (getActivity () getComponentName ()).); SearchView.clearFocus (); Super.onCreateOptionsMenu (menu, inflater); }

But a magnifier remains in other pieces, as well as typing a text at the top is also possible.

Is there a right way to show only a magnifier some pieces?

I have received an answer on another forum. Main activity in

:

  is boolean; @ Override the @ Public Bowlian mutation option menu (menu menu) {super.onPrepareOptionsMenu (menu); Menu.findItem (R.id.action_search) .setVisible (isVisible); Back true; }   

To update an actionbar, it should be said like this:

  invalidateOptionsMenu ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -