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:com.ririjin.adminmobile.fragment.UpdateBasiceFragment.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()); carlicense = ((UpdateCarActivity) getActivity()).gettcarLicense(); assetIdLinear = (LinearLayout) rootView.findViewById(R.id.assetId_linear); assetIdLinear.setVisibility(View.VISIBLE); AssetIdText = (TextView) rootView.findViewById(R.id.asset_id); AssetIdText.setText(assetId);/* www . j a v a2 s .co m*/ 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); AppraiserAsses = (EditText) rootView.findViewById(R.id.appraiser_asses); radioGroup = (RadioGroup) rootView.findViewById(R.id.cartype_radio); rZRadioButton = (RadioButton) rootView.findViewById(R.id.rongzi_btn); dYRadioButton = (RadioButton) rootView.findViewById(R.id.diya_btn); SaveButton.setOnClickListener(listener); CalculateButton.setOnClickListener(listener); postData = new RJPostData(getActivity().getApplicationContext(), apiUrl); CarLinseceEdit.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated method stub if (!hasFocus) { carlicense = GetCarLincese(CarLinseceEdit.getText().toString()); ((UpdateCarActivity) 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; } }); radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int arg1) { // TODO Auto-generated method stub } }); dialog.setMessage("?..."); dialog.setCancelable(false); dialog.show(); GetCarData(assetId); return rootView; }
From source file:net.xpece.android.support.preference.SeekBarPreference.java
/** * Listener reacting to the user pressing DPAD left/right keys if {@code * adjustable} attribute is set to true; it transfers the key presses to the SeekBar * to be handled accordingly./*from w ww . j a va 2s. c o m*/ */ private View.OnKeyListener buildSeekBarKeyListener(final SeekBar seekBar) { return new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() != KeyEvent.ACTION_DOWN) { return false; } if (!mAdjustable && (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT)) { // Right or left keys are pressed when in non-adjustable mode; Skip the keys. return false; } // We don't want to propagate the click keys down to the seekbar view since it will // create the ripple effect for the thumb. if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) { return false; } if (seekBar == null) { Log.e(TAG, "SeekBar view is null and hence cannot be adjusted."); return false; } return seekBar.onKeyDown(keyCode, event); } }; }
From source file:com.cianmcgovern.android.ShopAndShare.Share.java
@Override public void onCreate(Bundle savedInstanceState) { mContext = this; super.onCreate(savedInstanceState); setContentView(R.layout.share);// w ww . jav a2 s . c o m Button upload = (Button) findViewById(R.id.uploadButton); upload.setText(R.string.upload); upload.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String userLoc = mLocationEdit.getText().toString(); String userStore = mStore.getText().toString(); // Don't allow empty text fields if (userLoc.length() > 1 && userStore.length() > 1) { runUpload(Results.getInstance(), userLoc, userStore); } else new AlertDialog.Builder(mContext).setTitle(R.string.invalidInput) .setMessage(R.string.invalidFields).show(); } }); Button cancel = (Button) findViewById(R.id.cancelShareButton); cancel.setText(R.string.cancelButton); cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLocationListener != null) mLocationManager.removeUpdates(mLocationListener); finish(); } }); mLocationEdit = (EditText) findViewById(R.id.enterLocation); mLocationEdit.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mLocationEdit.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); return true; } return false; } }); mStore = (EditText) findViewById(R.id.enterStore); mStore.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction()) == KeyEvent.ACTION_DOWN && (keyCode == KeyEvent.KEYCODE_ENTER)) { InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(mStore.getApplicationWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); return true; } return false; } }); mSearch = (Button) findViewById(R.id.locationButton); mSearch.setBackgroundResource(R.drawable.search); mSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); if (!CheckFeatures.haveGPS()) { new AlertDialog.Builder(mContext).setTitle("GPS Required") .setMessage("You must have GPS to use this feature").show(); } // Only use GPS if it is enabled else if (mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { mSearch.setEnabled(false); mSearch.setBackgroundResource(R.drawable.world); getLocation(); } else { mGpsDialog = new AlertDialog.Builder(mContext).create(); mGpsDialog.setTitle(R.string.gpsDisabled); mGpsDialog.setMessage(mContext.getText(R.string.gpsDisabledMessage)); mGpsDialog.show(); } } }); }
From source file:de.da_sense.moses.client.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; getActionBar().hide();/*w w w.j a v a 2 s. c o m*/ setContentView(R.layout.login); lg = this; editTextEmail = (EditText) findViewById(R.id.login_email); editTextPassword = (EditText) findViewById(R.id.login_password); checkBoxRemember = (CheckBox) findViewById(R.id.checkbox_login_remember_me); buttonLogin = (Button) findViewById(R.id.login_button); // set the previously persisted credentials if any try { String[] credentials = readCredentials(); if (credentials != null) { editTextEmail.setText(credentials[0]); editTextPassword.setText(credentials[1]); } } catch (IOException e) { Log.e(LOG_TAG, "onCreate: file containing users credentials could not be read"); e.printStackTrace(); } // set the focus and cursor on an empty field (email or password) if (editTextEmail.getText().toString().isEmpty()) editTextEmail.requestFocus(); else if (editTextPassword.getText().toString().isEmpty()) editTextPassword.requestFocus(); /* * When user clicks the "Go" button on keyboard and the cursor is set on the password fields, * it should be equivalent to pressing the login button */ editTextPassword.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { lg.handleClick(buttonLogin); } return false; } }); }
From source file:org.chromium.chrome.browser.omnibox.LocationBarPhone.java
@Override public void setMenuButtonHelper(final AppMenuButtonHelper helper) { super.setMenuButtonHelper(helper); mMenuButton.setOnTouchListener(new OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override/*from ww w . ja v a 2s . co m*/ public boolean onTouch(View v, MotionEvent event) { return helper.onTouch(v, event); } }); mMenuButton.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View view, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) { return helper.onEnterKeyPress(view); } return false; } }); }
From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java
private void addEvent() { search_et.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { ToolsHelper.hideKeyBoard(getActivity()); String query = search_et.getText().toString(); if (query != null) { if (query.length() > 1 && baseLocal.size() > 0) { ArrayList<Track> tmp = new ArrayList<>(); for (int z = 0; z < baseLocal.size(); z++) { if (baseLocal.get(z).title.toLowerCase().contains(query.toLowerCase())) { tmp.add(baseLocal.get(z)); }// w w w . j a va2 s . c om } if (tmp.size() > 0) { localTracks = tmp; setUpList(localTracks); } else { ToolsHelper.toast(ctx, getString(R.string.nothing_found)); } } } return true; } return false; } }); search_et.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { final StringBuilder sb = new StringBuilder(charSequence.length()); sb.append(charSequence); String query = sb.toString(); if (query != null && baseLocal != null) { if (query.length() > 0 && baseLocal.size() > 0) { ArrayList<Track> tmp = new ArrayList<Track>(); for (int z = 0; z < baseLocal.size(); z++) { if (baseLocal.get(z).title.toLowerCase().contains(query.toLowerCase())) { tmp.add(baseLocal.get(z)); } } if (tmp.size() > 0) { localTracks = tmp; setUpList(localTracks); } // else { // ToolsHelper.toast(ctx, getString(R.string.nothing_found)); // } } } } @Override public void afterTextChanged(Editable editable) { } }); ref.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { try { getAllSongs(); setUpList(localTracks); } catch (Exception e) { e.printStackTrace(); } } }); back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ref.setVisibility(View.GONE); lnBack.setVisibility(View.GONE); mm.setVisibility(View.VISIBLE); showMenus(); } }); }
From source file:org.catrobat.catroid.ui.dialogs.OverwriteRenameDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_overwrite_project, null); replaceButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_rename); renameButton.setOnClickListener(this); projectText = (EditText) dialogView.findViewById(R.id.dialog_overwrite_project_edit); projectText.setText(programName);//from ww w . j a v a 2s. c om projectTextView = (TextView) dialogView.findViewById(R.id.dialog_overwrite_project_edit_text); projectTextLine = dialogView.findViewById(R.id.dialog_overwrite_project_edit_line); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(R.string.overwrite_text) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ToastUtil.showError(context, R.string.notification_download_project_cancel); } }).create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (okButtonResult) { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { ToastUtil.showError(context, R.string.notification_download_project_cancel); return true; } return false; } }); return dialog; }
From source file:tv.acfun.video.fragment.SearchFragment.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { startSearch(v.getText().toString(), 1); }/*www. jav a2 s .c o m*/ return false; }
From source file:com.trellmor.berrytubechat.ChatActivity.java
@SuppressLint("NewApi") @Override//from w w w .j ava 2s .co m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(false); } mEditChatMsg = (EditText) findViewById(R.id.edit_chat_msg); TextView.OnEditorActionListener chatMsgListener = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { sendChatMsg(); } else if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { sendChatMsg(); } return true; } }; mEditChatMsg.setOnEditorActionListener(chatMsgListener); mTextDrinks = (TextView) findViewById(R.id.text_drinks); registerForContextMenu(mTextDrinks); mCurrentVideo = (TextView) findViewById(R.id.text_video); mCurrentVideo.setMovementMethod(LinkMovementMethod.getInstance()); mTextNick = (TextView) findViewById(R.id.text_nick); mTextNick.setText("Anonymous"); mListChat = (ListView) findViewById(R.id.list_chat); Intent intent = getIntent(); mUsername = intent.getStringExtra(MainActivity.KEY_USERNAME); mPassword = intent.getStringExtra(MainActivity.KEY_PASSWORD); if (savedInstanceState != null) { mDrinkCount = savedInstanceState.getInt(KEY_DRINKCOUT); mMyDrinkCount = savedInstanceState.getInt(KEY_MYDRINKCOUNT); if (mUsername == null) mUsername = savedInstanceState.getString(MainActivity.KEY_USERNAME); if (mPassword == null) mPassword = savedInstanceState.getString(MainActivity.KEY_PASSWORD); } startService(new Intent(this, BerryTube.class)); bindService(new Intent(this, BerryTube.class), mService, BIND_ABOVE_CLIENT); }
From source file:org.xbmc.kore.ui.SendTextDialogFragment.java
/** * Create the dialog//from w w w. j ava 2 s . com * @param savedInstanceState Saved state * @return Created dialog */ @Override @SuppressWarnings("InflateParams") public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final String title = getArguments().getString(TITLE_KEY, getString(R.string.send_text)); View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_send_text, null); textToSend = (EditText) dialogView.findViewById(R.id.text_to_send); finishAfterSend = (CheckBox) dialogView.findViewById(R.id.send_text_done); builder.setTitle(title).setView(dialogView) .setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked()); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onSendTextCancel(); } }); final Dialog dialog = builder.create(); textToSend.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); textToSend.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { onSendTextFinished(); } // handles enter key on external keyboard, issue #99 else if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED && (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { onSendTextFinished(); } dialog.dismiss(); return false; } private void onSendTextFinished() { mListener.onSendTextFinished(textToSend.getText().toString(), finishAfterSend.isChecked()); } }); return dialog; }