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:com.sft.fragment.SchoolsFragment.java
private void initData() { searchSchool.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchSchool.setOnEditorActionListener(new OnEditorActionListener() { @Override//w ww . jav a2 s. c o m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { // ?? ((InputMethodManager) searchSchool.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); // ? LogUtil.print("?"); schoolname = searchSchool.getText().toString().trim(); searchSchool(true); return true; } return false; } }); }
From source file:com.near.chimerarevo.fragments.SearchFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);// w w w. jav a2 s .c o m ((BaseActivity) getActivity()).getToolbar().setTitle(getResources().getString(R.string.action_search)); mJson = new ArrayList<>(); arrayList = new ArrayList<>(); mAdapter = new PostsRecyclerAdapter(getActivity(), arrayList, false); mListView.setHasFixedSize(false); final LinearLayoutManager llm = new LinearLayoutManager(getActivity()); llm.setOrientation(LinearLayoutManager.VERTICAL); mListView.setLayoutManager(llm); mListView.setAdapter(mAdapter); mFab.attachToRecyclerView(mListView); mFab.setOnClickListener(this); mListView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); int visibleItemCount = llm.getChildCount(); int totalItemCount = llm.getItemCount(); int pastVisiblesItems = llm.findFirstVisibleItemPosition(); if ((visibleItemCount + pastVisiblesItems) < totalItemCount) { if (Math.abs(dy) > mScrollThreshold) { if (dy > 0) mFab.hide(); else mFab.show(); } } else mFab.show(); } }); if (readOfflineFile()) { clickCounter++; mFab.setEnabled(true); } mBtn.setOnClickListener(this); mText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (mText.getText().toString().length() > 0) { InputMethodManager in = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mText.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); mText.setError(null); mFab.setEnabled(true); performUpdate(); } else { mText.setError(getResources().getString(R.string.error_field_required)); mText.requestFocus(); } } return true; } }); }
From source file:net.olejon.mdapp.MedicationActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Intent/* ww w . ja v a 2 s . c om*/ final Intent intent = getIntent(); medicationId = intent.getLongExtra("id", 0); if (medicationId == 0) { mTools.showToast(getString(R.string.medication_could_not_find_medication), 1); finish(); return; } // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout setContentView(R.layout.activity_medication); // View mRelativeLayout = (RelativeLayout) findViewById(R.id.medication_inner_layout); // Toolbar mToolbar = (Toolbar) findViewById(R.id.medication_toolbar); mToolbar.setTitle(""); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbarSearchLayout = (LinearLayout) findViewById(R.id.medication_toolbar_search_layout); mToolbarSearchEditText = (EditText) findViewById(R.id.medication_toolbar_search); // View pager mViewPager = (ViewPager) findViewById(R.id.medication_pager); // Find in text mToolbarSearchEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { String find = mToolbarSearchEditText.getText().toString().trim(); if (find.equals("")) { if (mWebView != null) mWebView.clearMatches(); } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (mWebView != null) mWebView.findAllAsync(find); } else { if (mWebView != null) { //noinspection deprecation mWebView.findAll(find); } } } } @Override public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override public void afterTextChanged(Editable editable) { } }); 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); return true; } return false; } }); }
From source file:io.github.prefanatic.cleantap.ui.BeerSearchActivity.java
private void searchViewEvent(TextViewEditorActionEvent event) { if (event.actionId() == EditorInfo.IME_ACTION_SEARCH || (event.keyEvent().getKeyCode() == KeyEvent.KEYCODE_ENTER && event.keyEvent().getAction() == KeyEvent.ACTION_UP)) { recyclerView.setNestedScrollingEnabled(false); presenter.searchForBeer(searchView.getText().toString()); AnimUtils.show(progress);//from w ww. jav a 2s.co m AnimUtils.hide(helpText); } }
From source file:org.alfresco.mobile.android.application.fragments.site.search.SearchSitesFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) { return null; }/*from w ww . j av a2 s . c o m*/ setRootView(inflater.inflate(R.layout.fr_site_search, container, false)); init(getRootView(), emptyListMessageId); searchText = (MaterialAutoCompleteTextView) viewById(R.id.search_query); searchAdapter = new HistorySearchInlineCursorAdapter(this, null, R.layout.row_two_lines_search); getLoaderManager().initLoader(0, null, this); searchText.setAdapter(searchAdapter); searchText.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TwoLinesViewHolder vh = (TwoLinesViewHolder) view.getTag(); HistorySearch tmphistorySearchItem = HistorySearchManager.retrieveHistorySearch(getActivity(), (Long) vh.choose.getTag()); searchText.setText(tmphistorySearchItem.getQuery()); historySearchItem = tmphistorySearchItem; search(); } }); bAdd = (ImageButton) viewById(R.id.search_action); bAdd.setEnabled(false); activateSend(); bAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { search(); } }); searchText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { historySearchItem = null; activateSend(); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); searchText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (event != null && (event.getAction() == KeyEvent.ACTION_DOWN) && ((actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) { search(); return true; } return false; } }); return getRootView(); }
From source file:xyz.sahildave.widget.SearchViewLayout.java
@Override protected void onFinishInflate() { mCollapsed = (ViewGroup) findViewById(R.id.search_box_collapsed); mSearchIcon = findViewById(R.id.search_magnifying_glass); mCollapsedSearchBox = findViewById(R.id.search_box_start_search); mCollapsedHintView = (TextView) findViewById(R.id.search_box_collapsed_hint); mExpanded = (ViewGroup) findViewById(R.id.search_expanded_root); mSearchEditText = (EditText) mExpanded.findViewById(R.id.search_expanded_edit_text); mBackButtonView = mExpanded.findViewById(R.id.search_expanded_back_button); mExpandedSearchIcon = findViewById(R.id.search_expanded_magnifying_glass); // Convert a long click into a click to expand the search box, and then long click on the // search view. This accelerates the long-press scenario for copy/paste. mCollapsedSearchBox.setOnLongClickListener(new OnLongClickListener() { @Override/*from w ww . j a v a2 s. c o m*/ public boolean onLongClick(View view) { mCollapsedSearchBox.performClick(); mSearchEditText.performLongClick(); return false; } }); mCollapsed.setOnClickListener(mSearchViewOnClickListener); mSearchIcon.setOnClickListener(mSearchViewOnClickListener); mCollapsedSearchBox.setOnClickListener(mSearchViewOnClickListener); mSearchEditText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { Utils.showInputMethod(v); } else { Utils.hideInputMethod(v); } } }); mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { callSearchListener(); Utils.hideInputMethod(v); return true; } return false; } }); mSearchEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mSearchEditText.getText().length() > 0) { if (mExpandedSearchIcon.getVisibility() != View.VISIBLE) { Utils.fadeIn(mExpandedSearchIcon, ANIMATION_DURATION); } } else { Utils.fadeOut(mExpandedSearchIcon, ANIMATION_DURATION); } if (mSearchBoxListener != null) mSearchBoxListener.onTextChanged(s, start, before, count); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (mSearchBoxListener != null) mSearchBoxListener.beforeTextChanged(s, start, count, after); } @Override public void afterTextChanged(Editable s) { if (mSearchBoxListener != null) mSearchBoxListener.afterTextChanged(s); } }); mBackButtonView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { collapse(); } }); mExpandedSearchIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { callSearchListener(); Utils.hideInputMethod(v); } }); mCollapsedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.transparent)); mExpandedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), R.color.default_color_expanded)); mBackgroundTransition = new TransitionDrawable(new Drawable[] { mCollapsedDrawable, mExpandedDrawable }); mBackgroundTransition.setCrossFadeEnabled(true); setBackground(mBackgroundTransition); Utils.setPaddingAll(SearchViewLayout.this, 8); super.onFinishInflate(); }
From source file:com.gm.goldencity.activity.search.SearchActivity.java
public void setupSearchView() { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchview.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); // hint, inputType & ime options seem to be ignored from XML! Set in code searchview.setQueryHint(getString(R.string.search_hint)); searchview.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS); searchview.setImeOptions(searchview.getImeOptions() | EditorInfo.IME_ACTION_SEARCH | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN); }
From source file:de.incoherent.suseconferenceclient.activities.HomeActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuItem searchItem = menu.add(Menu.NONE, R.id.search, Menu.NONE, "Search"); searchItem.setIcon(R.drawable.search); searchItem.setActionView(R.layout.collapsable_search); searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); searchItem.setOnActionExpandListener(this); final EditText searchEdit = (EditText) searchItem.getActionView(); searchEdit.setOnEditorActionListener(new OnEditorActionListener() { @Override//from w w w . j a v a 2s. co m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { String query = v.getText().toString(); if (query.length() > 0) doSearch(query); searchItem.collapseActionView(); return true; } return false; } }); if (hasGoogleMaps()) { // With the phone layout, put the maps icon in the popup menu if (mPhonePager != null) { menu.add(Menu.CATEGORY_SYSTEM, R.id.mapsOptionMenuItem, 9, getString(R.string.mapsOptionMenuItem)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); } else { menu.add(Menu.NONE, R.id.mapsOptionMenuItem, Menu.NONE, getString(R.string.mapsOptionMenuItem)) .setIcon(R.drawable.icon_venue_off).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } } menu.add(Menu.CATEGORY_SYSTEM, R.id.filterEvents, 10, getString(R.string.filter)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); //menu.add(Menu.CATEGORY_SYSTEM, R.id.checkForUpdates, 11, getString(R.string.checkForUpdates)) //.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); menu.add(Menu.CATEGORY_SYSTEM, R.id.conferenceList, 12, getString(R.string.conferenceList)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); menu.add(Menu.CATEGORY_SYSTEM, R.id.aboutItem, 13, getString(R.string.menu_about)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); return super.onCreateOptionsMenu(menu); }
From source file:com.example.places.fragments.PlaceSearchFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); progressBar = (ProgressBar) view.findViewById(R.id.place_search_progressbar); recyclerView = (RecyclerView) view.findViewById(R.id.place_search_recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); actionButton = (FloatingActionButton) view.findViewById(R.id.place_search_toggle_button); actionButton.setOnClickListener(new View.OnClickListener() { @Override/*from w ww .ja v a 2s . com*/ public void onClick(View v) { onActionButtonClicked(); } }); currentPlaceCardView = (CardView) view.findViewById(R.id.current_place_cardview); currentPlaceCardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openCurrentPlaceDialog(); } }); currentPlaceNameTextView = (TextView) view.findViewById(R.id.current_place_name); currentPlaceAddressTextView = (TextView) view.findViewById(R.id.current_place_address); searchCardView = (CardView) view.findViewById(R.id.place_search_cardview); searchEditText = (EditText) view.findViewById(R.id.place_search_edittext); searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // When the search soft input key is clicked, // hide soft input and search nearby places if (actionId == EditorInfo.IME_ACTION_SEARCH) { InputMethodManager imm = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(searchEditText.getWindowToken(), 0); searchPlace(searchEditText.getText().toString()); } return true; } }); RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() { @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if (parent.getChildAdapterPosition(view) == 0) { outRect.top = getResources().getDimensionPixelOffset(R.dimen.place_search_list_header_height); } } }; recyclerView.addItemDecoration(itemDecoration); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); float elevation; if (recyclerView.canScrollVertically(SCROLL_DIRECTION_UP)) { elevation = getResources().getDimension(R.dimen.search_scrolling_elevation); } else { elevation = getResources().getDimension(R.dimen.search_resting_elevation); } ViewCompat.setElevation(currentPlaceCardView, elevation); ViewCompat.setElevation(searchCardView, elevation); } }); }
From source file:com.mg.axe.androiddevelop.view.SearchViewLayout.java
@Override protected void onFinishInflate() { mCollapsed = (ViewGroup) findViewById(R.id.search_box_collapsed); mSearchIcon = findViewById(R.id.search_magnifying_glass); mCollapsedSearchBox = findViewById(R.id.search_box_start_search); mCollapsedHintView = (TextView) findViewById(R.id.search_box_collapsed_hint); mExpanded = (ViewGroup) findViewById(R.id.search_expanded_root); mSearchEditText = (EditText) mExpanded.findViewById(R.id.search_expanded_edit_text); mBackButtonView = mExpanded.findViewById(R.id.search_expanded_back_button); mExpandedSearchIcon = findViewById(R.id.search_expanded_magnifying_glass); // Convert a long click into a click to expand the search box, and then long click on the // search view. This accelerates the long-press scenario for copy/paste. mCollapsedSearchBox.setOnLongClickListener(new OnLongClickListener() { @Override/* w w w . j ava2 s. c om*/ public boolean onLongClick(View view) { mCollapsedSearchBox.performClick(); mSearchEditText.performLongClick(); return false; } }); mCollapsed.setOnClickListener(mSearchViewOnClickListener); mSearchIcon.setOnClickListener(mSearchViewOnClickListener); mCollapsedSearchBox.setOnClickListener(mSearchViewOnClickListener); mSearchEditText.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { Utils.showInputMethod(v); } else { Utils.hideInputMethod(v); } } }); mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { callSearchListener(); Utils.hideInputMethod(v); return true; } return false; } }); mSearchEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mSearchEditText.getText().length() > 0) { if (mExpandedSearchIcon.getVisibility() != View.VISIBLE) { Utils.fadeIn(mExpandedSearchIcon, ANIMATION_DURATION); } } else { Utils.fadeOut(mExpandedSearchIcon, ANIMATION_DURATION); } if (mSearchBoxListener != null) mSearchBoxListener.onTextChanged(s, start, before, count); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (mSearchBoxListener != null) mSearchBoxListener.beforeTextChanged(s, start, count, after); } @Override public void afterTextChanged(Editable s) { if (mSearchBoxListener != null) mSearchBoxListener.afterTextChanged(s); } }); mBackButtonView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { collapse(); } }); mExpandedSearchIcon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { callSearchListener(); Utils.hideInputMethod(v); } }); mCollapsedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), android.R.color.transparent)); mExpandedDrawable = new ColorDrawable(ContextCompat.getColor(getContext(), R.color.default_color_expanded)); mBackgroundTransition = new TransitionDrawable(new Drawable[] { mCollapsedDrawable, mExpandedDrawable }); mBackgroundTransition.setCrossFadeEnabled(true); setBackgroundCompat(); Utils.setPaddingAll(SearchViewLayout.this, 8); super.onFinishInflate(); }