List of usage examples for android.content Context SEARCH_SERVICE
String SEARCH_SERVICE
To view the source code for android.content Context SEARCH_SERVICE.
Click Source Link
From source file:com.thelastcrusade.soundstream.CoreActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML getMenuInflater().inflate(R.menu.search_menu, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { searchView.setSearchableInfo(//from ww w . j ava2 s . c o m searchManager.getSearchableInfo(new ComponentName(this, SearchActivity.class))); searchView.setIconified(true); searchView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { v.setFocusable(true); v.requestFocusFromTouch(); } }); if (isConnectActive()) { searchItem.setVisible(false); } } return true; }
From source file:com.kiwiteam.nomiddleman.LargeGroupActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.global, menu); if (conn.isLogged()) { menu.findItem(R.id.account).setVisible(true); menu.findItem(R.id.signout).setVisible(true); } else {// w w w .j a v a 2s. c om menu.findItem(R.id.account).setVisible(false); menu.findItem(R.id.signout).setVisible(false); } //initSearchView(menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(searchableInfo); return true; }
From source file:com.andrew.apollo.ui.activities.SearchActivity.java
/** * {@inheritDoc}/*ww w.j ava 2 s . c om*/ */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getSupportMenuInflater().inflate(R.menu.search, menu); // Theme the search icon mResources.setSearchIcon(menu); // Filter the list the user is looking it via SearchView mSearchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); mSearchView.setOnQueryTextListener(this); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); mSearchView.setSearchableInfo(searchableInfo); return super.onCreateOptionsMenu(menu); }
From source file:org.bwgz.quotation.activity.SearchResultsActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu)); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); Intent intent = getIntent();/*ww w. ja v a 2 s. c o m*/ if (intent != null) { int type = intent.getIntExtra(EXTRA_SEARCH_TYPE, FreebaseSearch.SEARCH_TYPE_KEYWORD); Log.d(TAG, String.format("onCreateOptionsMenu - type: %s", type)); setSearchHint(menu, type); String query = intent.getStringExtra(SearchManager.QUERY); Log.d(TAG, String.format("onCreateOptionsMenu - query: %s", query)); if (query != null) { searchView.setIconified(true); searchView.setQuery(query, false); searchView.clearFocus(); } } return true; }
From source file:com.jhk.whysoformal.activity.musiclist.fragment.MusicListFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.menu_fragment_list_music, menu); MenuItem searchItem = menu.findItem(R.id.list_music_fragment_menu_item_search); SearchView searchView = (SearchView) searchItem.getActionView(); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); //SearchableInfo searchInfo = searchManager.getSearchableInfo(getActivity().getComponentName()); //searchView.setSearchableInfo(searchInfo); searchView.setOnQueryTextListener(this); }
From source file:edumsg.edumsg_android_app.MainActivity.java
/** * * The onCreate method first retrieves the sessionId and username from the parent {@link android.content.Intent}, * which is either created from a {@link LoginFragment} or a {@link RegisterFragment}. Afterwards, * it configures the action bar and performs view look-ups for the action bar buttons, followed * by setting the onClick listeners for the action bar buttons. Finally, it initializes the * properties, sets the onRefresh listener for the swipe refresh layout, and calls the method * {@link MainActivity#getFeed()}.//from w w w . ja v a2s. com * */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); sessionId = getIntent().getExtras().getString("sessionId"); username = getIntent().getExtras().getString("username"); setContentView(R.layout.activity_main); ButterKnife.bind(this); setSupportActionBar(toolbar); final ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_main, null); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(actionBarLayout); ImageButton homeButton = ButterKnife.findById(actionBarLayout, R.id.btn_home); final ImageButton searchButton = ButterKnife.findById(actionBarLayout, R.id.btn_search); ImageButton createButton = ButterKnife.findById(actionBarLayout, R.id.btn_create); ImageButton navButton = ButterKnife.findById(actionBarLayout, R.id.btn_nav); final ViewGroup searchLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.menu_search, null); final SearchView searchView = ButterKnife.findById(searchLayout, R.id.search); final ImageButton backBtn = ButterKnife.findById(searchLayout, R.id.btn_back); homeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); searchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actionBar.setCustomView(searchLayout); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager .getSearchableInfo(new ComponentName(MainActivity.this, SearchResultsActivity.class))); searchView.setQuery("", false); searchView.setIconified(false); searchView.setFocusable(true); searchView.requestFocusFromTouch(); } }); backBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { actionBar.setCustomView(actionBarLayout); InputMethodManager imm = (InputMethodManager) getApplicationContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow( MainActivity.this.getWindow().getDecorView().getRootView().getWindowToken(), 0); } }); createButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); final EditText input = new EditText(MainActivity.this); input.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE); input.setLines(4); input.setSingleLine(false); input.setBackgroundDrawable(null); builder.setView(input); builder.setPositiveButton("Tweet", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createTweet(input.getText().toString()); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { Button posBtn = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); posBtn.setBackgroundColor(cPrimary); posBtn.setTextColor(Color.WHITE); final float scale = getApplicationContext().getResources().getDisplayMetrics().density; int pixels = (int) (10 * scale + 0.5f); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, 0, pixels, 0); posBtn.setLayoutParams(layoutParams); Button negBtn = dialog.getButton(AlertDialog.BUTTON_POSITIVE); negBtn.setBackgroundColor(cPrimary); negBtn.setTextColor(Color.WHITE); } }); dialog.show(); } }); navButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fragmentManager = getSupportFragmentManager(); List<Fragment> fragments = fragmentManager.getFragments(); if (fragments != null) { for (Fragment fragment : fragments) { if (fragment instanceof NavigationFragment) return; } } NavigationFragment navigationFragment = new NavigationFragment(); // Bundle bundle = new_user Bundle(); // bundle.putInt("userId", userId); // mainActivityFragment.setArguments(bundle); fragmentManager.beginTransaction().add(android.R.id.content, navigationFragment) .addToBackStack("nav").commit(); // logout(); // launchMessages(); // Intent intent = new_user Intent(MainActivity.this, ProfileActivity.class); // intent.putExtra("username", getUsername()); // intent.putExtra("name", getName()); // intent.putExtra("avatar_url", getAvatar_url()); // intent.putExtra("bio", getBio()); // intent.putExtra("creatorId", getUserId()); // intent.putExtra("userId", getUserId()); // startActivity(intent); } }); recyclerView.setHasFixedSize(true); final float scale = getApplicationContext().getResources().getDisplayMetrics().density; int pixels = (int) (160 * scale + 0.5f); Paint paint = new Paint(); paint.setStrokeWidth(3.0f); paint.setColor(Color.rgb(220, 220, 220)); paint.setAntiAlias(true); recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(this).paint(paint).build()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(linearLayoutManager); tweetObjects = new ArrayList<>(); rvAdapter = new RVAdapter(this, tweetObjects, sessionId); recyclerView.setAdapter(rvAdapter); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { tweetObjects.clear(); getFeed(); } }); getFeed(); }
From source file:com.ksharkapps.musicnow.ui.activities.SearchActivity.java
/** * {@inheritDoc}/*from ww w .ja v a 2s . c o m*/ */ @Override public boolean onCreateOptionsMenu(final Menu menu) { // Search view getMenuInflater().inflate(R.menu.search, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); // Filter the list the user is looking it via SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (mSearchView != null) mSearchView.setOnQueryTextListener(this); // Add voice search final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); mSearchView.setSearchableInfo(searchableInfo); return super.onCreateOptionsMenu(menu); }
From source file:com.vnapnic.streamgames.ui.TDActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main, menu); refreshItem = menu.findItem(R.id.menu_refresh); searchItem = menu.findItem(R.id.menu_search); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setOnQueryTextFocusChangeListener(this); return true;/* w w w . ja v a 2s . c o m*/ }
From source file:org.freespanish.diccionario.fragments.search.SearchFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.search_menu, menu); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); searchView.setMaxWidth(Integer.MAX_VALUE); this.menu = menu; }
From source file:ru.neverdark.phototools.azimuth.PluginActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { Log.enter();// ww w . j a v a2s . c om getMenuInflater().inflate(R.menu.main, menu); mMenuItemSearch = menu.findItem(R.id.item_search); mMenuItemTZ = menu.findItem(R.id.item_timeZone); mMenuSave = menu.findItem(R.id.item_saveLocation); if (Constants.PAID) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) MenuItemCompat.getActionView(mMenuItemSearch); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); searchView.setQueryHint(getString(R.string.search_hint)); searchView.setOnQueryTextListener(new QueryTextListener()); } else { MenuItemCompat.setActionView(mMenuItemSearch, null); } return true; }