0
I need to know how when people give enter in the search bar, the application pass what was typed to another Fragment and start it.
Currently I arrived at the following code, but it is not working.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.pesquisa, menu);
super.onCreateOptionsMenu(menu,inflater);
//Pega o Componente.
SearchView mSearchView = (SearchView) menu.findItem(R.id.search)
.getActionView();
//Define um texto de ajuda:
mSearchView.setQueryHint("teste");
if (Intent.ACTION_SEARCH.equals(getActivity().getIntent().getAction())) {
Intent intent = null;
String query = intent.getStringExtra(SearchManager.QUERY);
}
// exemplos de utilização:
doMySearch(query);
return;
}
public void doMySearch(String query) {
Search serach = new Search();
Fragment myListFragment = getFragmentManager().findFragmentByTag("ListFragment");
Bundle bundle = new Bundle();
bundle.putString("QUERY",query);
serach.setArguments(bundle);
}