public static void setupEditText(Activity activity, final Enterable ent, EditText et) { OnEditorActionListener tveal = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { ent.onEnter(); return true; } return false; } }; et.setOnEditorActionListener(tveal); et.requestFocus(); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); }
private void initViews() { getVerifiCodeButton = getView(R.id.btn_send_verifi_code); getVerifiCodeButton.setOnClickListener(this); phoneEdit = getView(R.id.et_phone); phoneEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);// 下一步 verifyCodeEdit = getView(R.id.et_verifiCode); verifyCodeEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);// 下一步 passwordEdit = getView(R.id.et_password); passwordEdit.setImeOptions(EditorInfo.IME_ACTION_DONE); passwordEdit.setImeOptions(EditorInfo.IME_ACTION_GO); passwordEdit.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // 点击虚拟键盘的done if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_GO) { commit(); } return false; } }); }
protected void createPasswordPinView(int paramInt1, int paramInt2) { this.mMainView.findViewById(2131755690).setVisibility(0); this.mPasswordView = ((EditText)this.mMainView.findViewById(paramInt1)); this.mPasswordView.setVisibility(0); this.mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { public final boolean onEditorAction(TextView paramAnonymousTextView, int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent) { if (paramAnonymousInt == 6) { PurchaseAuthenticationChallengeBaseStep.this.logClickAndSubmitResponse(true); return true; } return false; } }); this.mPasswordView.setHintTextColor(ContextCompat.getColor(((PurchaseFragment)this.mParentFragment).getContext(), 2131689798)); this.mHelpToggleView = ((ImageView)this.mMainView.findViewById(2131755691)); this.mHelpToggleView.setOnClickListener(this); this.mHelpToggleView.setContentDescription(getString(paramInt2)); this.mErrorView = ((TextView)this.mMainView.findViewById(2131755481)); if (!TextUtils.isEmpty(this.mErrorMessage)) { showErrorMessage(this.mErrorMessage); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Firebase.setAndroidContext(this); setContentView(R.layout.activity_main); mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Plus.API) .addScope(Plus.SCOPE_PLUS_LOGIN) .build(); firebase = new Firebase(Consts.FIREBASE_URL); username = (TextView) findViewById(R.id.username); userImage = (ImageView) findViewById(R.id.user_image); code = (EditText) findViewById(R.id.code); code.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { join(); return true; } }); code.requestFocus(); }
private void initView() { View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_input_number, null); et_number = (EditText) view.findViewById(R.id.et_number); tv_name = (TextView) view.findViewById(R.id.tv_name); view.findViewById(R.id.btn_ok).setOnClickListener(this); view.findViewById(R.id.btn_close).setOnClickListener(this); addView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); et_number.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub if (actionId == EditorInfo.IME_ACTION_DONE) { inputOk(); } return false; } }); }
private void setCommentView() { if (entry.canComment()) { edtNewCom.setEnabled(true); edtNewCom.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((actionId == EditorInfo.IME_ACTION_SEND && !TextUtils.isEmpty(edtNewCom.getText().toString())) || (actionId == EditorInfo.IME_NULL && event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) doInsComment(edtNewCom.getText().toString()); return false; } }); } else { edtNewCom.setEnabled(false); edtNewCom.setOnEditorActionListener(null); edtNewCom.setText(R.string.entry_cant_comm); } }
public DelegatingEditText(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(VERTICAL); mContext = context; LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.delegating_edit_text, this, /* attachToRoot */ true); messageView = (TextView) findViewById(R.id.edit_text_message); delegateEditText = (EditText) findViewById(R.id.delegate_edit_text); delegateEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionCode, KeyEvent event) { messageView.setText("typed: " + delegateEditText.getText()); messageView.setVisibility(View.VISIBLE); InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(delegateEditText.getWindowToken(), 0); return true; } }); }
@Override protected void installListeners() { // TODO Auto-generated method stub mEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub if (actionId == EditorInfo.IME_ACTION_GO) { try { Integer page = Integer.valueOf(mEditText.getText() .toString()); if (page > 0 && page <= mMaxPages) { mCurrentPage = page; loadPage(); } } catch (Exception e) { // TODO: handle exception } } return false; } }); }
@Override public View onCreateActionView() { // Inflate the action view to be shown on the action bar. LayoutInflater layoutInflater = LayoutInflater.from(mContext); View view = layoutInflater.inflate(R.layout.edit_weight_layout, null); text = (EditText) view.findViewById(R.id.weightText); text.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { if (text.getText().toString() != null) { weight = Integer .parseInt(text.getText().toString()); } } return false; } }); return view; }
private void populateNewCommentInputView(View newCommentView, final Post post) { // User's image ImageView ivPosterProfile = (ImageView) newCommentView.findViewById(R.id.ivPosterProfile); ivPosterProfile.setImageResource(ModelUtils.getImageResourceForUser((User) User .getCurrentUser())); final EditText etComment = (EditText) newCommentView.findViewById(R.id.etComment); etComment.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_SEND) { SaveCommentListener saveCommentListener = (SaveCommentListener) (LCDetailsActivity) getContext(); saveCommentListener.onSaveComment( post.getObjectId(), etComment.getText().toString()); handled = true; } return handled; } }); }
private void initDataToComponent(String query ){ if(editTextVenue == null) { editTextVenue = ( EditText) findViewById( R.id.editTextVenue); } if(query!=null && !query.equals( "")) { editTextVenue.setText( query); editTextVenue.setTextIsSelectable( true); editTextVenue.setFocusable( true); editTextVenue.setFocusableInTouchMode( true); } editTextVenue.setOnEditorActionListener( new OnEditorActionListener( ){ @Override public boolean onEditorAction( TextView v, int actionId, KeyEvent event){ searchVenue( editTextVenue.getText( ).toString( ), lat, lng); return false; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_layout_changes); mContainerView = (ViewGroup) findViewById(R.id.container); edittext = (EditText) findViewById(R.id.editbox); edittext.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(!edittext.getEditableText().toString().trim().equals("")) { mylist.add(edittext.getEditableText().toString()); addItem(mylist.size()-1); edittext.setText(""); } return true; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* Verification du mot de passe lors du clic sur 'Ok' du clavier */ ((EditText) findViewById(R.id.motDePasse)) .setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { toMenu(v); return true; } }); manageFileProcedureUsed(); }
private void setSearchBarEnterAction() { final EditText searchBar = (EditText) findViewById(R.id.searchBar); searchBar.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { searchQuery = searchBar.getText().toString(); cleanSearchQuery(); sendSearchRequest(); return true; } else { return false; } } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pickup_uri); //Set window size // LayoutParams params = getWindow().getAttributes(); // params.width = LayoutParams.FILL_PARENT; // getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); //Set title // TODO -- use dialog instead // ((TextView) findViewById(R.id.my_title)).setText(R.string.pickup_sip_uri); // ((ImageView) findViewById(R.id.my_icon)).setImageResource(android.R.drawable.ic_menu_call); okBtn = (Button) findViewById(R.id.ok); okBtn.setOnClickListener(this); Button btn = (Button) findViewById(R.id.cancel); btn.setOnClickListener(this); sipUri = (EditSipUri) findViewById(R.id.sip_uri); sipUri.getTextField().setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView tv, int action, KeyEvent arg2) { if(action == EditorInfo.IME_ACTION_GO) { sendPositiveResult(); return true; } return false; } }); sipUri.setShowExternals(false); }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.sync_custom_passphrase, null); mEnterPassphrase = (EditText) view.findViewById(R.id.passphrase); mConfirmPassphrase = (EditText) view.findViewById(R.id.confirm_passphrase); mConfirmPassphrase.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { tryToSubmitPassphrase(); } return false; } }); TextView instructionsView = (TextView) view.findViewById(R.id.custom_passphrase_instructions); instructionsView.setMovementMethod(LinkMovementMethod.getInstance()); instructionsView.setText(getInstructionsText()); AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) .setView(view) .setTitle(R.string.sync_passphrase_type_custom_dialog_title) .setPositiveButton(R.string.save, null) .setNegativeButton(R.string.cancel, null) .create(); dialog.getDelegate().setHandleNativeActionModesEnabled(false); return dialog; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.console); // setTitle("Loopback test"); mReception = (EditText) findViewById(R.id.EditTextReception); EditText Emission = (EditText) findViewById(R.id.EditTextEmission); Emission.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { int i; CharSequence t = v.getText(); char[] text = new char[t.length()]; for (i = 0; i < t.length(); i++) { text[i] = t.charAt(i); } try { mOutputStream.write(new String(text).getBytes()); mOutputStream.write('\n'); } catch (IOException e) { e.printStackTrace(); } return false; } }); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.search_fragment, container, false); searchBarIV = (ImageView) rootView.findViewById(R.id.search); searchBarIV.setOnClickListener(this); iconIV = (ImageView) rootView.findViewById(R.id.searchIcon); iconIV.setOnClickListener(this); text = (TextView) rootView.findViewById(R.id.text); text.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)) { Bundle searchTag = new Bundle(); searchTag.putString(SEARCH_TAG_KEY, text.getText().toString().trim()); ((MainActivity)getActivity()).moveToPhotosFragment(searchTag); //startActivity(new Intent(getActivity(), FriendsActivity.class)); } return false; } }); searchToBar = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_search_to_bar); barToSearch = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_bar_to_search); interp = AnimationUtils.loadInterpolator(this.getActivity(), android.R.interpolator.linear_out_slow_in); duration = getResources().getInteger(R.integer.duration_bar); // iv is sized to hold the search+bar so when only showing the search icon, translate the // whole view left by half the difference to keep it centered offset = -71f * (int) getResources().getDisplayMetrics().scaledDensity; searchBarIV.setTranslationX(offset); rootView.setOnClickListener(this); return rootView; }
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { super.onCreateDialog(savedInstanceState); LayoutInflater inflater = getActivity().getLayoutInflater(); View view = inflater.inflate(R.layout.sync_custom_passphrase, null); mEnterPassphrase = (EditText) view.findViewById(R.id.passphrase); mConfirmPassphrase = (EditText) view.findViewById(R.id.confirm_passphrase); mConfirmPassphrase.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { tryToSubmitPassphrase(); } return false; } }); AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) .setView(view) .setTitle(R.string.sync_passphrase_type_custom) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .create(); dialog.getDelegate().setHandleNativeActionModesEnabled(false); return dialog; }
public static OnEditorActionListener getSoftInputHideEditorActionListener(final Context context, final EditText editText) { OnEditorActionListener hideEditorListener = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { EditTextUtil.hideSoftInPut(editText, context); return true; } return false; } }; return hideEditorListener; }
public void setOnEditorActionListener(OnEditorActionListener listener) { ((JTextField)this.component).addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { listener.onEditorAction(EditText.this, 0, new KeyEvent()); } }); }
private void popInput() { if(mPwdEdit!=null) { mPwdEdit.postDelayed(new Runnable() { @Override public void run() { mPwdEdit.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mPwdEdit, InputMethodManager.SHOW_FORCED); } }, 100); OnEditorActionListener eal = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView edit, int id, KeyEvent event) { if(id == EditorInfo.IME_ACTION_DONE) { onConfirm(null); return true; } return false; } }; EditText et_confirm = (EditText)findViewById(R.id.confirm); if(et_confirm.getVisibility() == View.VISIBLE) { mPwdEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT); et_confirm.setOnEditorActionListener(eal); } else { mPwdEdit.setOnEditorActionListener(eal); } } }
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { for (OnEditorActionListener l : mOnEditorActionListener) { l.onEditorAction(v, actionId, event); return true; } return false; }
@Override protected void installListeners() { // TODO Auto-generated method stub mSearchEditText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub if (actionId == EditorInfo.IME_ACTION_GO) { onSearchClick(null); } return false; } }); }
private void inicializarEditText() { mEtRespuesta.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId) { checkSolution(); } return false; } }); }
/** * @param runnable * @param imeActionId * @param views */ public void onEditorAction(final EditTextRunnable runnable, final int imeActionId, final EditText... views) { onEditorAction(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { return imeActionId == actionId && runnable.run(); } }, views); }
/** * @param runnable * @param imeActionId * @param views */ public void onEditorAction(final EditTextRunnable runnable, final int imeActionId, final FloatLabelAutoCompleteTextView... views) { onEditorAction(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { return imeActionId == actionId && runnable.run(); } }, views); }
/** * @param listener * @param views */ public void onEditorAction(final OnEditorActionListener listener, final FloatLabelAutoCompleteTextView... views) { for (final FloatLabelAutoCompleteTextView view : views) { if (view != null) { view.setOnEditorActionListener(listener); } } }
/** * @param runnable * @param imeActionId * @param views */ public void onEditorAction(final EditTextRunnable runnable, final int imeActionId, final FloatLabelEditText... views) { onEditorAction(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { return imeActionId == actionId && runnable.run(); } }, views); }
/** * @param listener * @param views */ public void onEditorAction(final OnEditorActionListener listener, final FloatLabelEditText... views) { for (final FloatLabelEditText view : views) { if (view != null) { view.setOnEditorActionListener(listener); } } }
/** * @param listener * @param views */ public void onEditorAction(final OnEditorActionListener listener, final EditText... views) { for (final EditText view : views) { if (view != null) { view.setOnEditorActionListener(listener); } } }