List of usage examples for android.view KeyEvent KEYCODE_ENTER
int KEYCODE_ENTER
To view the source code for android.view KeyEvent KEYCODE_ENTER.
Click Source Link
From source file:org.tanrabad.team.ChatFragment.java
private void initUiComponents(View rootView) { mListView = (ListView) rootView.findViewById(R.id.list); turnOffListViewDecoration(mListView); mListView.setAdapter(mAdapter);//ww w .ja v a 2 s . c o m mBtnChannel = (ImageButton) rootView.findViewById(R.id.btn_channel); mBtnSend = (Button) rootView.findViewById(R.id.btn_send); mBtnUpload = (ImageButton) rootView.findViewById(R.id.btn_upload); mProgressBtnUpload = (ProgressBar) rootView.findViewById(R.id.progress_btn_upload); mEtxtMessage = (EditText) rootView.findViewById(R.id.etxt_message); mBtnSend.setEnabled(false); mBtnSend.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { send(); } }); mBtnChannel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mHandler != null) { mHandler.onChannelListClicked(); } } }); mBtnUpload.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_PICK_IMAGE); } }); mEtxtMessage.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (event.getAction() == KeyEvent.ACTION_DOWN) { send(); } return true; // Do not hide keyboard. } return false; } }); mEtxtMessage.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); mEtxtMessage.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { mBtnSend.setEnabled(s.length() > 0); } }); mListView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { SoftKeyboard.hide(getActivity()); return false; } }); mListView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == SCROLL_STATE_IDLE) { if (view.getFirstVisiblePosition() == 0 && view.getChildCount() > 0 && view.getChildAt(0).getTop() == 0) { resultHandler = new MessageListQuery.MessageListQueryResult() { @Override public void onResult(List<MessageModel> messageModels) { for (MessageModel model : messageModels) { mAdapter.addMessageModel(model); } mAdapter.notifyDataSetChanged(); mListView.setSelection(messageModels.size()); } @Override public void onError(Exception e) { } }; SendBird.queryMessageList(SendBird.getChannelUrl()).prev(mAdapter.getMinMessageTimestamp(), 30, resultHandler); } } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { } }); }
From source file:com.luyaozhou.recognizethisforglass.ViewFinder.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_CAMERA: { // camera button (hardware) if (keyEnable) { camera.stopPreview(); // stop the preview camera.release(); // release the camera previewOn = false;/*from www . j a v a 2 s . com*/ keyEnable = false; mHandler.post(new Runnable() { @Override public void run() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, PHOTO_REQUEST_CODE); } } }); } // Return false to allow the camera button to do its default action return false; } case KeyEvent.KEYCODE_DPAD_CENTER: // touchpad tap case KeyEvent.KEYCODE_ENTER: { if (keyEnable) { camera.stopPreview(); camera.release(); previewOn = false; // Don't release the camera in surfaceDestroyed() keyEnable = false; mHandler.post(new Runnable() { @Override public void run() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // capture image if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, PHOTO_REQUEST_CODE); } } }); } return false; } default: { return super.onKeyDown(keyCode, event); } } }
From source file:com.openerp.base.login.Login.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);//from w w w. j av a 2 s .com this.context = getActivity(); scope = new AppScope(this); // Inflate the layout for this fragment rootView = inflater.inflate(R.layout.fragment_login, container, false); dbListSpinner = (Spinner) rootView.findViewById(R.id.lstDatabases); this.handleArguments((Bundle) getArguments()); this.loadDatabaseList(); getActivity().setTitle(R.string.label_login); getActivity().getActionBar().setDisplayHomeAsUpEnabled(false); getActivity().getActionBar().setHomeButtonEnabled(false); edtUsername = (EditText) rootView.findViewById(R.id.edtUsername); edtPassword = (EditText) rootView.findViewById(R.id.edtPassword); edtPassword.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { goNext(); } return false; } }); return rootView; }
From source file:com.se.cronus.AbstractCActivity.java
/** * /*from ww w . ja v a2 s.c om*/ */ protected void setUpOnClicks() { // extract soon item.setOnClickListener(this); search.setOnClickListener(this); refresh.setOnClickListener(this); searchTextV.setClickable(true); searchTextV.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) return false; if (keyCode == KeyEvent.KEYCODE_ENTER) { // your necessary codes... onSearchClick(); return true; } if (keyCode == KeyEvent.KEYCODE_SEARCH) { // your necessary codes... onSearchClick(); return true; } return false; } }); searchTextV.setOnClickListener(this); }
From source file:com.battlelancer.seriesguide.ui.MoviesSearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_movies_search, container, false); ButterKnife.inject(this, v); // setup grid view resultsGridView.setEmptyView(emptyView); resultsGridView.setOnItemClickListener(this); // setup search box searchBox.setThreshold(1);//from w w w. ja v a 2s. c om searchBox.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { search(); return true; } return false; } }); searchBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ((AutoCompleteTextView) v).showDropDown(); } }); searchBox.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { search(); } }); // set in code as XML is overridden searchBox.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchBox.setInputType(EditorInfo.TYPE_CLASS_TEXT); // setup clear button clearButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { searchBox.setText(null); searchBox.requestFocus(); } }); setProgressVisible(false, false); return v; }
From source file:com.ririjin.adminmobile.fragment.BasicFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View rootView = inflater.inflate(R.layout.basic_fragment, container, false);// ? dialog = new ProgressDialog(getActivity()); assetIdLinear = (LinearLayout) rootView.findViewById(R.id.assetId_linear); assetIdLinear.setVisibility(View.VISIBLE); SaveButton = (Button) rootView.findViewById(R.id.save_btn); CalculateButton = (Button) rootView.findViewById(R.id.calculate_btn); CarLinseceEdit = (EditText) rootView.findViewById(R.id.carlinsece_edit); ContractFilter = (EditText) rootView.findViewById(R.id.contract_filter); CarFactorAssess = (EditText) rootView.findViewById(R.id.car_factor_assess); AppraiserAsses = (EditText) rootView.findViewById(R.id.appraiser_asses); SaveButton.setOnClickListener(listener); CalculateButton.setOnClickListener(listener); postData = new RJPostData(getActivity().getApplicationContext(), apiUrl); CarLinseceEdit.setOnFocusChangeListener(new OnFocusChangeListener() { @Override/*from ww w.jav a2 s.c o m*/ public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated method stub if (!hasFocus) { if (CarLinseceEdit.getText().toString().length() != 7) { Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT) .show(); ContractFilter.setText(""); } else { carlicense = GetCarLincese(CarLinseceEdit.getText().toString()); ((AddCarAcitivity) getActivity()).setcarLicense(carlicense); ContractFilter.setText(SFTP.GetNowTime() + carlicense); } } } }); CarLinseceEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { Log.d(TAG, "" + actionId + "," + event); if (actionId == EditorInfo.IME_ACTION_DONE || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { // do something; CarLinseceEdit.clearFocus(); return true; } return false; } }); return rootView; }
From source file:net.olejon.mdapp.NasjonaleRetningslinjerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Input manager mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Layout/* www.ja v a 2s. c om*/ setContentView(R.layout.activity_nasjonale_retningslinjer); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.nasjonale_retningslinjer_toolbar); toolbar.setTitle(getString(R.string.nasjonale_retningslinjer_title)); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mToolbarSearchLayout = (LinearLayout) findViewById(R.id.nasjonale_retningslinjer_toolbar_search_layout); mToolbarSearchEditText = (EditText) findViewById(R.id.nasjonale_retningslinjer_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.nasjonale_retningslinjer_toolbar_clear_search); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mToolbarSearchEditText.setText(""); } }); // Progress bar mProgressBar = (ProgressBar) findViewById(R.id.nasjonale_retningslinjer_toolbar_progressbar); // Floating action button mFloatingActionButton = (FloatingActionButton) findViewById(R.id.nasjonale_retningslinjer_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); } } }); // List mListView = (ListView) findViewById(R.id.nasjonale_retningslinjer_list); View listViewEmpty = findViewById(R.id.nasjonale_retningslinjer_list_empty); mListView.setEmptyView(listViewEmpty); View listViewHeader = getLayoutInflater().inflate(R.layout.activity_nasjonale_retningslinjer_list_subheader, mListView, false); mListView.addHeaderView(listViewHeader, null, false); }
From source file:com.ibm.mil.readyapps.telco.onboarding.appintrolib.AppIntro.java
@Override public boolean onKeyDown(int code, KeyEvent kvent) { if (code == KeyEvent.KEYCODE_ENTER || code == KeyEvent.KEYCODE_BUTTON_A) { ViewPager vp = (ViewPager) this.findViewById(R.id.view_pager); if (vp.getCurrentItem() == vp.getAdapter().getCount() - 1) { onDonePressed();//w ww . j a v a 2s . c o m } else { vp.setCurrentItem(vp.getCurrentItem() + 1); } return false; } return super.onKeyDown(code, kvent); }
From source file:org.chromium.content_shell.Shell.java
private void initializeUrlField() { mUrlTextView = (EditText) findViewById(R.id.url); mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() { @Override//from w w w. j a v a 2 s . co m public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null || event.getKeyCode() != KeyEvent.KEYCODE_ENTER || event.getAction() != KeyEvent.ACTION_DOWN)) { return false; } loadUrl(mUrlTextView.getText().toString()); setKeyboardVisibilityForUrl(false); mContentView.requestFocus(); return true; } }); mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { setKeyboardVisibilityForUrl(hasFocus); mNextButton.setVisibility(hasFocus ? GONE : VISIBLE); mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE); if (!hasFocus) { mUrlTextView.setText(mContentView.getUrl()); } } }); }
From source file:net.eledge.android.europeana.gui.activity.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); getSupportActionBar().setDisplayHomeAsUpEnabled(true); NewBlogNotification.cancel(this); PreferenceManager.setDefaultValues(this, R.xml.settings, false); searchController.suggestionPageSize = getResources().getInteger(R.integer.home_suggestions_pagesize); isLandscape = getResources().getBoolean(R.bool.home_support_landscape); mSuggestionsAdaptor = new SuggestionAdapter(this, new ArrayList<Item>()); mGridViewSuggestions.setAdapter(mSuggestionsAdaptor); mGridViewSuggestions.setOnItemClickListener(this); mEditTextQuery.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/* w w w . j a v a 2s .c om*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { performSearch(v.getText().toString()); return true; } return false; } }); mEditTextQuery.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (s.length() > 2) { if (mGridViewSuggestions.isShown()) { mSuggestionsAdaptor.clear(); mSuggestionsAdaptor.notifyDataSetChanged(); } searchController.suggestions(HomeActivity.this, s.toString()); } else { onTaskFinished(null); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // ignore } @Override public void afterTextChanged(Editable s) { // ignore } }); mProfilesAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item); mSpinnerProfiles.setAdapter(mProfilesAdapter); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (mBlogFragment == null) { mBlogFragment = new HomeBlogFragment(); } fragmentTransaction.replace(R.id.activity_home_fragment_blog, mBlogFragment); fragmentTransaction.commit(); }