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:Main.java
/** * Used to alter the edit text so that when they click the bottom right button on their, * keyboard, it will simulate an enter press * @param et Edit text being altered/*ww w . jav a2 s .co m*/ * @param listener Listener to decide the reaction to said click * @param <T> T extends Edit Text */ private static <T extends EditText> void addIMEFunctionality(T et, TextView.OnEditorActionListener listener) { et.setImeOptions(EditorInfo.IME_ACTION_SEARCH); et.setImeActionLabel("Enter", KeyEvent.KEYCODE_ENTER); et.setOnEditorActionListener(listener); /* et.setImeOptions(EditorInfo.IME_ACTION_SEARCH); et.setImeActionLabel("Enter", KeyEvent.KEYCODE_ENTER); et.setOnEditorActionListener(listener); @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId == KeyEvent.KEYCODE_ENTER){ doStuff(); } if(actionId == EditorInfo.IME_ACTION_SEARCH){ doStuff(); } return false; } //Make sure to include this code below in class calling this method/ function @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId == KeyEvent.KEYCODE_ENTER){ //Action happens here, IE Submit or enter } if(actionId == EditorInfo.IME_ACTION_SEARCH){ //Action happens here, IE Submit or enter } return false; } */ }
From source file:de.appetites.android.menuItemSearchAction.MenuItemSearchAction.java
public MenuItemSearchAction(Context context, Menu menu, SearchPerformListener searchPerformListener, Drawable drawable, TextWatcher text, LinearLayout list) { super(context); this.searchPerformListener = searchPerformListener; this.context = context; createMenuItem(menu, drawable, list); // show search button on keyboard; this needs the setting of TYPE_TEXT... to be shown setImeOptions(EditorInfo.IME_ACTION_SEARCH); setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); setMaxLines(1);//ww w . ja va 2 s .c o m this.addTextChangedListener(text); }
From source file:com.ran.pics.activity.ImageSearchResultActivity.java
private void initEvent() { etSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override//from w ww .j a v a 2 s . c o m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (etSearch.getText().toString().trim().equals("")) { ToastUtil.showShort(etSearch, ""); return false; } UILApplication.missKeyBoard(ImageSearchResultActivity.this); imageGridFragment.search(etSearch.getText().toString().trim()); return true; } return false; } }); }
From source file:net.thetabx.gcd.activity.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); header = (TextView) findViewById(R.id.txt_chat_header); listView = (ListView) findViewById(R.id.lview_chat); swipe = (SwipeRefreshLayout) findViewById(R.id.swipe_chat); swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override/* w ww . j a v a 2s . c o m*/ public void onRefresh() { fetchFreshData(); } }); edit = (EditText) findViewById(R.id.etxt_chat_send); edit.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { header.setText(String.format("Sent %s", v.getText())); sendChatMessage(v); //v.setText(""); fetchFreshData(); } return false; } }); header.setText("Start"); if (messages == null) { fetchFreshData(); } else fillActivity(); }
From source file:com.fabioarias.ui.Search.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.search, null); View scanView = (View) view.findViewById(R.id.p2); searchField = (EditText) view.findViewById(R.id.editText1); setTouchNClick(view.findViewById(R.id.p1)); setTouchNClick(scanView);/* w w w . java2 s.com*/ searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView vv, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { // BUSQUEDA POR CRITERIA search(searchField.getText().toString()); return true; } return false; } }); this.v = view; if (scan != null) { search(scan); } return view; }
From source file:mobisocial.bento.todo.ui.TodoDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // extract UUID from intent mTodoUuid = getActivity().getIntent().getStringExtra(EXTRA_TODO_UUID); // View/*from w w w . ja va2 s .co m*/ mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_todo_detail, container); mTitle = (EditText) mRootView.findViewById(R.id.todo_title); mDescription = (EditText) mRootView.findViewById(R.id.todo_description); mDescription.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { Log.d(TAG, "onEditorAction"); // clear focus v.clearFocus(); // close keyboard InputMethodManager mgr = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); mgr.hideSoftInputFromWindow(mDescription.getWindowToken(), 0); return true; } return false; } }); mImageView = (ImageView) mRootView.findViewById(R.id.todo_image); // retrieve Todo data if (mTodoUuid != null) { mTodoItem = mManager.getTodoListItem(mTodoUuid); if (mTodoItem != null) { mTitle.setText(mTodoItem.title); mDescription.setText(mTodoItem.description); if (mTodoItem.hasImage) { mImageView.setImageBitmap(mManager.getTodoBitmap(mTodoItem.uuid, IMG_WIDTH, IMG_HEIGHT, 0)); mImageView.setVisibility(View.VISIBLE); } else { mImageView.setVisibility(View.GONE); } } } return mRootView; }
From source file:org.quantumbadger.redreader.views.SearchListingHeader.java
public SearchListingHeader(final Activity parentActivity, final SearchPostListURL url) { super(parentActivity); mUrl = url;/*from www . j a v a 2s . c o m*/ LayoutInflater layoutInflater = (LayoutInflater) parentActivity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); layoutInflater.inflate(R.layout.search_listing_header, this, true); mQuery = (EditText) findViewById(R.id.search_listing_header_query_editText); mQuery.setText(url.query); mQuery.setImeOptions(EditorInfo.IME_ACTION_NEXT); mSubreddit = (EditText) findViewById(R.id.search_listing_header_sub_editText); // null and "all" are isomorphic; but SearchPostListURL takes null if (url.subreddit == null) { mSubreddit.setText("all"); } else { mSubreddit.setText(url.subreddit); } TextView.OnEditorActionListener onEnter = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { performSearch(parentActivity, mSubreddit, mQuery); return true; } }; mSubreddit.setImeOptions(EditorInfo.IME_ACTION_SEARCH); mSubreddit.setOnEditorActionListener(onEnter); mSearchButton = (Button) findViewById(R.id.search_listing_header_search); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { performSearch(parentActivity, mSubreddit, mQuery); } }); }
From source file:info.wncwaterfalls.app.SearchWaterfallFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View waterfallSearchFragmentView = inflater.inflate(R.layout.fragment_waterfall_search, container, false); // Up-set the Find button. Button b = (Button) waterfallSearchFragmentView.findViewById(R.id.search_waterfall_find_button); b.setOnClickListener(this); // Set up edit text for search button in keyboard EditText waterfalltextBox = (EditText) waterfallSearchFragmentView .findViewById(R.id.search_waterfall_name_textbox); waterfalltextBox.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from w ww . ja v a 2s. c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { performLocationSearch(); return true; } return false; } }); return waterfallSearchFragmentView; }
From source file:net.meiolania.apps.habrahabr.fragments.users.UsersFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.users_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(), UsersSearchActivity.class); intent.putExtra(UsersSearchActivity.EXTRA_QUERY, searchQuery.getText().toString()); startActivity(intent);//from w ww .java2 s . c o m return true; } return false; } }); super.onCreateOptionsMenu(menu, inflater); }
From source file:net.meiolania.apps.habrahabr.fragments.hubs.HubsFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater 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 . ja va 2 s . c o m*/ return true; } return false; } }); super.onCreateOptionsMenu(menu, inflater); }