List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_SEARCH
int IME_ACTION_SEARCH
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_SEARCH.
Click Source Link
From source file:net.meiolania.apps.habrahabr.fragments.qa.AbstractionQaFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.qa_fragment, menu); final EditText searchQuery = (EditText) menu.findItem(R.id.search).getActionView() .findViewById(R.id.search_query); searchQuery.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Intent intent = new Intent(getSherlockActivity(), QaSearchActivity.class); intent.putExtra(QaSearchActivity.EXTRA_QUERY, searchQuery.getText().toString()); startActivity(intent);//www . j a va2s . co m return true; } return false; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:net.meiolania.apps.habrahabr.fragments.posts.AbstractionPostsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.posts_fragment, menu); final EditText searchQuery = (EditText) menu.findItem(R.id.search).getActionView() .findViewById(R.id.search_query); searchQuery.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Intent intent = new Intent(getSherlockActivity(), PostsSearchActivity.class); intent.putExtra(PostsSearchActivity.EXTRA_QUERY, searchQuery.getText().toString()); startActivity(intent);/* w w w.j a v a 2 s.co m*/ return true; } return false; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.maxwen.wallpaper.board.fragments.WallpaperSearchFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_wallpaper_search, menu); MenuItem search = menu.findItem(R.id.menu_search); int color = ColorHelper.getAttributeColor(getActivity(), R.attr.toolbar_icon); search.setIcon(DrawableHelper.getTintedDrawable(getActivity(), R.drawable.ic_toolbar_search, color)); mSearchView = (SearchView) MenuItemCompat.getActionView(search); mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_SEARCH); mSearchView.setQueryHint(getActivity().getResources().getString(R.string.menu_search)); mSearchView.setMaxWidth(Integer.MAX_VALUE); MenuItemCompat.expandActionView(search); mSearchView.setIconifiedByDefault(false); mSearchView.clearFocus();//from w w w.ja v a2 s. c om ViewHelper.changeSearchViewTextColor(mSearchView, color, ColorHelper.setColorAlpha(color, 0.6f)); View view = mSearchView.findViewById(android.support.v7.appcompat.R.id.search_plate); if (view != null) view.setBackgroundColor(Color.TRANSPARENT); ImageView closeIcon = (ImageView) mSearchView .findViewById(android.support.v7.appcompat.R.id.search_close_btn); if (closeIcon != null) closeIcon.setImageResource(R.drawable.ic_toolbar_close); ImageView searchIcon = (ImageView) mSearchView .findViewById(android.support.v7.appcompat.R.id.search_mag_icon); ViewHelper.removeSearchViewSearchIcon(searchIcon); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String string) { filterSearch(string); return true; } @Override public boolean onQueryTextSubmit(String string) { mSearchView.clearFocus(); return true; } }); }
From source file:com.rascarlo.aurdroid.ui.SearchFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { context = container.getContext();/*from w ww . jav a 2s. c om*/ FragmentSearchBinding fragmentSearchBinding = FragmentSearchBinding.inflate(LayoutInflater.from(context), container, false); TextInputEditText textInputEditText = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputEditText; textInputEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); textInputEditText.setOnEditorActionListener((editTextView, actionId, event) -> { if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (editTextView.getEditableText() != null && !TextUtils.isEmpty(editTextView.getEditableText().toString().trim())) { if (searchFragmentCallback != null) { searchFragmentCallback.onSearchFragmentCallbackOnFabClicked(getSearchBy(), getSort(), editTextView.getEditableText().toString().trim()); } } InputMethodManager inputMethodManager = (InputMethodManager) editTextView.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) inputMethodManager.hideSoftInputFromWindow(editTextView.getWindowToken(), 0); return true; } return false; }); // search by radioButtonSearchByNameOrDescription = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonNameOrDescription; radioButtonSearchByName = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonName; radioButtonSearchByMaintainer = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonMaintainer; radioButtonSearchByDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonDepends; radioButtonSearchByMakeDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonMakeDepends; radioButtonSearchByOptDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonOptDepends; radioButtonSearchByCheckDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonCheckDepends; // sort radioButtonSortPackageName = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonPackageName; radioButtonSortVotes = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonVotes; radioButtonSortPopularity = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonPopularity; radioButtonSortLastUpdated = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonLastUpdated; radioButtonSortFirstSubmitted = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonFirstSubmitted; bindViews(); return fragmentSearchBinding.getRoot(); }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysKeybaseFragment.java
/** * Inflate the layout for this fragment//from w w w .ja v a 2s. c o m */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.import_keys_keybase_fragment, container, false); mQueryEditText = (EditText) view.findViewById(R.id.import_keybase_query); mSearchButton = (BootstrapButton) view.findViewById(R.id.import_keybase_search); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String query = mQueryEditText.getText().toString(); search(query); // close keyboard after pressing search InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mQueryEditText.getWindowToken(), 0); } }); mQueryEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { String query = mQueryEditText.getText().toString(); search(query); // Don't return true to let the keyboard close itself after pressing search return false; } return false; } }); return view; }
From source file:com.survivingwithandroid.weatherapp.settings.SearchLocationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_location_activity); client = WeatherContext.getInstance().getClient(this); Log.d("App", "Client [" + client + "]"); cityListView = (ListView) findViewById(R.id.cityList); bar = (ProgressBar) findViewById(R.id.progressBar2); adp = new CityAdapter(SearchLocationActivity.this, new ArrayList<City>()); cityListView.setAdapter(adp);//from ww w . ja v a 2 s . c om ImageView searchView = (ImageView) findViewById(R.id.imgSearch); final EditText edt = (EditText) findViewById(R.id.cityEdtText); edt.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { search(v.getText().toString()); return true; } return false; } }); searchView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { search(edt.getEditableText().toString()); } }); cityListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { SharedPreferences sharedPref = PreferenceManager .getDefaultSharedPreferences(SearchLocationActivity.this); SharedPreferences.Editor editor = sharedPref.edit(); City city = (City) parent.getItemAtPosition(pos); editor.putString("cityid", city.getId()); editor.putString("cityName", city.getName()); editor.putString("country", city.getCountry()); editor.commit(); NavUtils.navigateUpFromSameTask(SearchLocationActivity.this); } }); ImageView locImg = (ImageView) findViewById(R.id.imgLocationSearch); locImg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bar.setVisibility(View.VISIBLE); try { client.searchCityByLocation(WeatherClient.createDefaultCriteria(), new WeatherClient.CityEventListener() { @Override public void onCityListRetrieved(List<City> cityList) { bar.setVisibility(View.GONE); adp.setCityList(cityList); adp.notifyDataSetChanged(); } @Override public void onWeatherError(WeatherLibException wle) { bar.setVisibility(View.GONE); } @Override public void onConnectionError(Throwable t) { bar.setVisibility(View.GONE); } }); } catch (LocationProviderNotFoundException lpnfe) { } } }); }
From source file:com.github.jobs.ui.fragment.SOUserPickerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);//from w ww .jav a 2s . c o m FragmentManager fm = getFragmentManager(); mSOUserFetcherReceiver = (SOUserFetcherReceiver) fm.findFragmentByTag(ReceiverFragment.TAG); if (mSOUserFetcherReceiver == null) { mSOUserFetcherReceiver = new SOUserFetcherReceiver(); fm.beginTransaction().add(mSOUserFetcherReceiver, ReceiverFragment.TAG).commitAllowingStateLoss(); } mUserSearch = (EditText) getView().findViewById(R.id.edit_user_search); mUserSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { executeSearch(mUserSearch.getText().toString().trim()); return true; } return false; } }); ListView userList = (ListView) getView().findViewById(R.id.users_list); mAdapter = new SOUsersAdapter(getActivity()); if (savedInstanceState != null && savedInstanceState.containsKey(KEY_USERS)) { ArrayList<Parcelable> items = savedInstanceState.getParcelableArrayList(KEY_USERS); ArrayList<SOUser> users = new ArrayList<SOUser>(); for (Parcelable item : items) { users.add((SOUser) item); } mAdapter.updateItems(users); } userList.setOnItemClickListener(this); userList.setAdapter(mAdapter); String search = getActivity().getIntent().getStringExtra(SOUserPickerActivity.EXTRA_SEARCH); if (search == null) { if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH)) { search = savedInstanceState.getString(KEY_SEARCH); mUserSearch.setText(search); mUserSearch.setSelection(search.length()); } else { search = ""; } } mUserSearch.setText(search); mUserSearch.setSelection(search.length()); if (savedInstanceState == null) { // this will execute search only the first time the activity is open executeSearch(search); } }
From source file:com.fusionx.lightirc.ui.IRCFragment.java
@Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { final CharSequence text = mMessageBox.getText(); if ((event == null || actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) && StringUtils.isNotEmpty(text)) { final String message = text.toString(); mMessageBox.setText(""); onSendMessage(message);/*from ww w. j a va 2 s.co m*/ return true; } return false; }
From source file:net.meiolania.apps.habrahabr.fragments.hubs.HubsMainFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.hubs_fragment, menu); final EditText searchQuery = (EditText) menu.findItem(R.id.search).getActionView() .findViewById(R.id.search_query); searchQuery.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Intent intent = new Intent(getSherlockActivity(), HubsSearchActivity.class); intent.putExtra(HubsSearchActivity.EXTRA_QUERY, searchQuery.getText().toString()); startActivity(intent);/*from w w w.j a v a 2 s . c o m*/ return true; } return false; } }); }
From source file:net.olejon.mdapp.Icd10Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout/*from w ww . ja v a 2s . com*/ setContentView(R.layout.activity_icd10); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.icd10_toolbar); toolbar.setTitle(getString(R.string.icd10_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbarSearchLayout = (LinearLayout) findViewById(R.id.icd10_toolbar_search_layout); mToolbarSearchEditText = (EditText) findViewById(R.id.icd10_toolbar_search); mToolbarSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_SEARCH || keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) { mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0); search(mToolbarSearchEditText.getText().toString().trim()); return true; } return false; } }); ImageButton imageButton = (ImageButton) findViewById(R.id.icd10_toolbar_clear_search); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mToolbarSearchEditText.setText(""); } }); // List mListView = (ListView) findViewById(R.id.icd10_list); // Floating action button mFloatingActionButton = (FloatingActionButton) findViewById(R.id.icd10_fab); mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mToolbarSearchLayout.getVisibility() == View.VISIBLE) { mInputMethodManager.hideSoftInputFromWindow(mToolbarSearchEditText.getWindowToken(), 0); search(mToolbarSearchEditText.getText().toString().trim()); } else { mToolbarSearchLayout.setVisibility(View.VISIBLE); mToolbarSearchEditText.requestFocus(); mInputMethodManager.showSoftInput(mToolbarSearchEditText, 0); } } }); // Get chapters GetChaptersTask getChaptersTask = new GetChaptersTask(); getChaptersTask.execute(); }