Java Code Examples for android.widget.SearchView

The following are top voted examples for showing how to use android.widget.SearchView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: ViewPagerVentasLista.java   View source code 9 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuInflater menuInflater = new MenuInflater(rootView.getContext());
    menuInflater.inflate(R.menu.menu_ventas_lista, menu);
    MenuItem item = menu.findItem(R.id.item_buscar);
    SearchView searchView = (SearchView)item.getActionView();

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }
        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    super.onCreateOptionsMenu(menu, inflater);

}
 
Example 2
Project: q-mail   File: ChooseFolder.java   View source code 6 votes vote down vote up
private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
Example 3
Project: LaunchEnr   File: IconChooser.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.search_menu, menu);

    MenuItem search = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) search.getActionView();
    initQueryTextListener(searchView);

    return true;
}
 
Example 4
Project: LaunchEnr   File: IconChooser.java   View source code 6 votes vote down vote up
private void initQueryTextListener(SearchView searchView) {

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

                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {

                IconsSearchUtils.filter(newText, matchingIcons, allIcons, mGridAdapter);
                return true;
            }
        });
    }
 
Example 5
Project: NeverCrash   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_main, menu);

    menu.findItem(R.id.item_show_system).setChecked(mSharedPreferences.getBoolean(PREF_SHOW_SYSTEM, false));
    menu.findItem(R.id.item_show_toast).setChecked(mSharedPreferences.getBoolean(PREF_TOAST, true));
    mSearchView = (SearchView) menu.findItem(R.id.item_search).getActionView();
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            filterApps(app -> app.name.toLowerCase().contains(query.toLowerCase()) || app.packageName.toLowerCase().contains(query.toLowerCase()));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            filterApps(app -> app.name.toLowerCase().contains(newText.toLowerCase()) || app.packageName.toLowerCase().contains(newText.toLowerCase()));
            return true;
        }
    });
    return true;
}
 
Example 6
Project: editor   File: Editor.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

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

    if (searchView != null)
    {
        searchView.setSubmitButtonEnabled(true);
        searchView.setImeOptions(EditorInfo.IME_ACTION_GO);
        searchView.setOnQueryTextListener(new QueryTextListener());
    }

    return true;
}
 
Example 7
Project: GithubProject   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);

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

    searchView.setQueryHint(getResources().getString(R.string.search_hint));

    return true;
}
 
Example 8
Project: MOPP-Android   File: BrowseContainersListFragment.java   View source code 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    List<File> containers = FileUtils.getContainers(getActivity());

    final ContainerListAdapter containerListAdapter = new ContainerListAdapter(getActivity(), containers);
    setListAdapter(containerListAdapter);

    SearchView searchView = (SearchView) getActivity().findViewById(R.id.listSearch);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            containerListAdapter.getFilter().filter(newText);
            return false;
        }
    });
    searchView.setQuery("", false);
    getActivity().findViewById(R.id.content_browse_containers).requestFocus();
}
 
Example 9
Project: K9-MailClient   File: ChooseFolder.java   View source code 6 votes vote down vote up
private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
Example 10
Project: PowerToggles   File: IconPackPicker.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  SearchView searchView = new SearchView(this);
  searchView.setSearchableInfo(((SearchManager) getSystemService(Context.SEARCH_SERVICE)).getSearchableInfo(getComponentName()));
  searchView.setOnQueryTextListener(this);

  menu.add(android.R.string.search_go)
    .setIcon(android.R.drawable.ic_menu_search)
    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW + MenuItem.SHOW_AS_ACTION_ALWAYS)
    .setActionView(searchView)
    .setOnActionExpandListener(this);

  if (mShowTint) {
    MenuItem item = menu.add(R.string.wc_tint);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    item.setActionView(R.layout.ab_color_btn);
    ColorButton cb = (ColorButton) item.getActionView().findViewById(R.id.btn_tint);
    cb.setColor(mAdapter.mColorFilter);
    cb.setOnColorChangeListener(this, true);
  }
  return true;
}
 
Example 11
Project: Cook-E   File: RecipeList.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_home_list, container, false);
    final ListView recipeList = (ListView) view.findViewById(R.id.list_view);
    recipeList.setAdapter(new RecipeListAdapter(getActivity(), mRecipes));
    // Configure list for testing
    recipeList.setTag(R.id.test_tag_recipe_list, "Recipe List");
    
    // Search
    mSearchView = (SearchView) view.findViewById(R.id.search);
    mSearchView.setOnQueryTextListener(new SearchHandler());

    // Empty view, shown when list is empty
    final TextView emptyView = (TextView) view.findViewById(R.id.empty_list_view);
    emptyView.setText(R.string.no_recipes);
    if (mRecipes.isEmpty()) {
        emptyView.setVisibility(View.VISIBLE);
    } else {
        emptyView.setVisibility(View.INVISIBLE);
    }
    mRecipes.addOnListChangedCallback(new ListEmptyViewManager(emptyView));

    return view;
}
 
Example 12
Project: RxJava2-Android-Samples   File: RxSearchObservable.java   View source code 6 votes vote down vote up
public static Observable<String> fromView(SearchView searchView) {

        final PublishSubject<String> subject = PublishSubject.create();

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String s) {
                subject.onComplete();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String text) {
                subject.onNext(text);
                return true;
            }
        });

        return subject;
    }
 
Example 13
Project: GoogleBookReader-android   File: BookListFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

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

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

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
}
 
Example 14
Project: mytracks   File: Api11Adapter.java   View source code 6 votes vote down vote up
@Override
public void configureSearchWidget(
    Activity activity, MenuItem menuItem, final TrackController trackController) {
  SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menuItem.getActionView();
  searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
  searchView.setQueryRefinementEnabled(true);
  searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
    
      @Override
    public void onFocusChange(View v, boolean hasFocus) {
        // Hide and show trackController when search widget has focus/no focus
        if (trackController != null) {
          if (hasFocus) {
            trackController.hide();
          } else {
            trackController.show();
          }
        }        
    }
  });
}
 
Example 15
Project: instantsearch-android   File: InstantSearch.java   View source code 6 votes vote down vote up
private void linkSearchViewToSearcher(@NonNull final SearchViewFacade searchView) {
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        // SearchView.OnQueryTextListener

        @Override
        public boolean onQueryTextSubmit(String query) {
            EventBus.getDefault().post(new QueryTextSubmitEvent());
            // Nothing to do: the search has already been performed by `onQueryTextChange()`.
            // We do try to close the keyboard, though.
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            EventBus.getDefault().post(new QueryTextChangeEvent(newText, searchView.getSearchView()));

            if (newText.length() == 0 && !searchOnEmptyString) {
                return true;
            }
            searcher.setQuery(searcher.getQuery().setQuery(searchView.getQuery().toString()))
                    .search();
            return true;
        }
    });
}
 
Example 16
Project: instantsearch-android   File: SearchViewFacade.java   View source code 6 votes vote down vote up
/**
 * Sets a listener for user actions within the SearchView.
 *
 * @param listener the listener object that receives callbacks when the user performs
 *                 actions in the SearchView such as clicking on buttons or typing a query.
 */
public void setOnQueryTextListener(@NonNull final SearchView.OnQueryTextListener listener) {
    if (searchView != null) {
        searchView.setOnQueryTextListener(listener);
    } else if (supportView != null) {
        supportView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
            @Override public boolean onQueryTextSubmit(String query) {
                return listener.onQueryTextSubmit(query);
            }

            @Override public boolean onQueryTextChange(String newText) {
                return listener.onQueryTextChange(newText);
            }
        });
    } else {
        throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
    }
}
 
Example 17
Project: instantsearch-android   File: SearchViewFacade.java   View source code 6 votes vote down vote up
/**
 * Sets a listener for user actions within the SearchView.
 *
 * @param listener the listener object that receives callbacks when the user performs
 *                 actions in the SearchView such as clicking on buttons or typing a query.
 */
public void setOnQueryTextListener(@NonNull final android.support.v7.widget.SearchView.OnQueryTextListener listener) {
    if (searchView != null) {
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override public boolean onQueryTextSubmit(String query) {
                return listener.onQueryTextSubmit(query);
            }

            @Override public boolean onQueryTextChange(String newText) {
                return listener.onQueryTextChange(newText);
            }
        });
    } else if (supportView != null) {
        supportView.setOnQueryTextListener(listener);
    } else {
        throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
    }
}
 
Example 18
Project: Reminders   File: Reminders.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(R.menu.activity_main, menu);

       // Associate searchable configuration with the SearchView
       SearchManager searchManager =
               (SearchManager) getSystemService(Context.SEARCH_SERVICE);
       searchMenuItem = menu.findItem(R.id.search);
       final SearchView searchView =
               (SearchView) searchMenuItem.getActionView();
       searchView.setSearchableInfo(
               searchManager.getSearchableInfo(getComponentName()));
       searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
           @Override
           public void onFocusChange(View view, boolean queryTextFocused) {
               if(!queryTextFocused) {
                   searchMenuItem.collapseActionView();
                   searchView.setQuery("", false);
               }
           }
       });

	return true;
}
 
Example 19
Project: Movie-Time-Spent   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.share_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);

    if (searchItem != null) {
        mSearchView = (SearchView) searchItem.getActionView();
    }

    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setIconified(false);
        mSearchView.setQueryHint(getString(R.string.search_view_hint));
        mSearchView.setMaxWidth(getResources().getDimensionPixelOffset(R.dimen.BU_22));
    }
    setListenerForSearchView();
    return super.onCreateOptionsMenu(menu);
}
 
Example 20
Project: MalwareBuster   File: MainActivity.java   View source code 6 votes vote down vote up
private void refreshGlobalHookControls() {
    boolean currentStatus = prefs.getBoolean(Common.GLOBALHOOK, false);

    ImageButton glbHookbtn = (ImageButton)findViewById(R.id.btnGlobalHook);
    ListView list = (ListView) findViewById(R.id.lstApps);
    TextView globalWarningTextView = (TextView) findViewById(R.id.globalWarningTextView);
    SearchView searchApp = (SearchView) findViewById(R.id.searchApp);

    if (currentStatus) {
        glbHookbtn.setBackgroundColor(0xff34bcf1);
        list.setVisibility(View.GONE);
        globalWarningTextView.setVisibility(View.VISIBLE);
        searchApp.setEnabled(false);
    }
    else {
        glbHookbtn.setBackgroundColor(Color.DKGRAY);
        list.setVisibility(View.VISIBLE);
        globalWarningTextView.setVisibility(View.GONE);
        searchApp.setEnabled(true);
    }
}
 
Example 21
Project: MalwareBuster   File: MainActivity.java   View source code 6 votes vote down vote up
private void prepareAppList() {
    final AppListAdapter appListAdapter = new AppListAdapter(MainActivity.this, appList);

    ((ListView) findViewById(R.id.lstApps)).setAdapter(appListAdapter);
    //appListAdapter.getFilter().filter(nameFilter);
    ((SearchView) findViewById(R.id.searchApp)).setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            nameFilter = query;
            appListAdapter.getFilter().filter(nameFilter);
            ((SearchView) findViewById(R.id.searchApp)).clearFocus();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            nameFilter = newText;
            appListAdapter.getFilter().filter(nameFilter);
            return false;
        }

    });
}
 
Example 22
Project: FastContactsLoader   File: ContactsActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_contacts, menu);
    searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (contactListFragment != null) {
                contactListFragment.onSearch(newText);
            }
            return true;
        }
    });

    return true;
}
 
Example 23
Project: daxSmail   File: ChooseFolder.java   View source code 6 votes vote down vote up
private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
Example 24
Project: shorty   File: LookupActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    // Inflate the menu; this adds items to the action bar if it
    // is present.
    getMenuInflater().inflate(R.menu.lookup, menu);

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

    if (searchView != null)
    {
        searchView.setQueryHint(getText(R.string.hint));
        searchView.setOnQueryTextListener(this);
    }

    return true;
}
 
Example 25
Project: Android-Applications-Info   File: MainListFragment.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    mProgressDialog = new ProgressDialog(mActivity);
    mProgressDialog.setTitle(R.string.loading_apps);
    mProgressDialog.setCancelable(false);

    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setDisplayShowCustomEnabled(true);

    SearchView searchView = new SearchView(actionBar.getThemedContext());
    searchView.setOnQueryTextListener(this);

    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    actionBar.setCustomView(searchView, layoutParams);

    if (savedInstanceState != null) {
        int sortBy = savedInstanceState.getInt(INSTANCE_STATE_SORT_BY, -1);
        if (sortBy != -1)
            setSortBy(sortBy);
    }
}
 
Example 26
Project: RxAutocompleteSample   File: AddressAutocompleteActivity.java   View source code 6 votes vote down vote up
@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_address_autocomplete, menu);

    MenuItem item = menu.findItem(R.id.action_search);
    item.expandActionView(); // get focus
    SearchView searchView = (SearchView) item.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override public boolean onQueryTextSubmit(String query) {
            autocompleteInteractor.onQueryChange(query);
            return true;
        }

        @Override public boolean onQueryTextChange(String newText) {
            autocompleteInteractor.onQueryChange(newText);
            return true;
        }
    });

    return true;
}
 
Example 27
Project: ApkLauncher   File: ContentBrowserActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new org.bbs.apklauncher.emb.IntentHelper(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 28
Project: ApkLauncher   File: WindowFocusObserver.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new org.bbs.apklauncher.emb.IntentHelper(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 29
Project: ApkLauncher   File: VideoPlayerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new org.bbs.apklauncher.emb.IntentHelper(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 30
Project: pushetta-android-app   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu items for use in the action bar
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.main_activity_actions, menu);

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

	searchView.setSearchableInfo(searchManager
			.getSearchableInfo(new ComponentName(this,
					ChannelSearchActivity.class)));
	searchView.setIconifiedByDefault(false);
	searchView.setSubmitButtonEnabled(true);

	return super.onCreateOptionsMenu(menu);
}
 
Example 31
Project: edx-app-android   File: CourseDiscussionPostsSearchFragment.java   View source code 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    discussionTopicsSearchView.setQuery(searchQuery, false);
    discussionTopicsSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (query == null || query.trim().isEmpty())
                return false;
            SoftKeyboardUtil.hide(getActivity());
            searchQuery = query;
            nextPage = 1;
            controller.reset();
            discussionPostsListView.setVisibility(View.INVISIBLE);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
}
 
Example 32
Project: ApiDemos   File: ContentBrowserActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 33
Project: ApiDemos   File: WindowFocusObserver.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 34
Project: ApiDemos   File: ContentBrowserNavActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 35
Project: ApiDemos   File: SystemUIModes.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.content_actions, menu);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);

    // Set file with share history to the provider and set the share intent.
    MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
    ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
    actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    // Note that you can set/change the intent any time,
    // say when the user has selected an image.
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("image/*");
    Uri uri = Uri.fromFile(getFileStreamPath("shared.png"));
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    actionProvider.setShareIntent(shareIntent);
    return true;
}
 
Example 36
Project: MyCTFWriteUps   File: SearchViewCompatHoneycomb.java   View source code 6 votes vote down vote up
public static Object newOnCloseListener(OnCloseListenerCompatBridge oncloselistenercompatbridge)
{
    return new android.widget.SearchView.OnCloseListener(oncloselistenercompatbridge) {

        final OnCloseListenerCompatBridge val$listener;

        public boolean onClose()
        {
            return listener.onClose();
        }

        
        {
            listener = oncloselistenercompatbridge;
            super();
        }
    };
}
 
Example 37
Project: V-Scan   File: Lookup.java   View source code 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu){

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

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.search_bar);

    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(this);

    return super.onCreateOptionsMenu(menu);
}
 
Example 38
Project: Makadu_Android   File: Tab_EventDetail_Talk_Paper.java   View source code 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    inflater.inflate(R.menu.menu_tab_detalhe_evento_programacao, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search_tab_detalhe_programacao);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(mQueryTextListenerTalk);

    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            ArrayList<Talk> list_talk = new ArrayList<Talk>();

            list_talk = (ArrayList<Talk>) new TalkDao(getActivity().getApplicationContext()).getListTalkForEventIdTAB_TALK(Long.parseLong(obj_event.id));

            agrupamento(getActivity().getApplicationContext(), list_talk, false);

            adapterTalk.notifyDataSetChanged();

            return false;
        }
    });
}
 
Example 39
Project: q-mail   File: FolderList.java   View source code 5 votes vote down vote up
private void configureFolderSearchView(Menu menu) {
    final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
    final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
    folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
    folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            folderMenuItem.collapseActionView();
            mActionBarTitle.setText(getString(R.string.filter_folders_action));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mAdapter.getFilter().filter(newText);
            return true;
        }
    });

    folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            mActionBarTitle.setText(getString(R.string.folders_title));
            return false;
        }
    });
}
 
Example 40
Project: GitHub   File: FlickrSearchActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.search_activity, menu);

  searchView =
      (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search));
  searchView.setSubmitButtonEnabled(true);
  searchView.setIconified(false);
  searchView.setOnQueryTextListener(this);

  return true;
}