android.widget.TextView.OnEditorActionListener Java Examples
The following examples show how to use
android.widget.TextView.OnEditorActionListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignUpActivity.java From A-week-to-develop-android-app-plan with Apache License 2.0 | 6 votes |
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; } }); }
Example #2
Source File: ViewChatRecordActivity.java From yiim_v2 with GNU General Public License v2.0 | 6 votes |
@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; } }); }
Example #3
Source File: CollectActivity.java From Field-Book with GNU General Public License v2.0 | 6 votes |
private OnEditorActionListener createOnEditorListener(final EditText edit, final String searchType) { return new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { // do not do bit check on event, crashes keyboard if (actionId == EditorInfo.IME_ACTION_DONE) { try { moveToSearch(searchType, rangeID, null, null, view.getText().toString()); InputMethodManager imm = parent.getIMM(); imm.hideSoftInputFromWindow(edit.getWindowToken(), 0); } catch (Exception ignore) { } return true; } return false; } }; }
Example #4
Source File: DelegatingEditText.java From android-test with Apache License 2.0 | 6 votes |
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; } }); }
Example #5
Source File: MainActivity.java From cloud-cup-android with Apache License 2.0 | 6 votes |
@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(); }
Example #6
Source File: SignUpActivity.java From A-week-to-develop-android-app-plan with Apache License 2.0 | 6 votes |
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; } }); }
Example #7
Source File: X8FixedEditText.java From FimiX8-RE with MIT License | 6 votes |
public X8FixedEditText(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId != 6 && event.getAction() != 4 && event.getAction() != 1) { return false; } if (X8FixedEditText.this.listener != null) { try { int value = Integer.valueOf(X8FixedEditText.this.getText().toString()).intValue(); if (value < X8FixedEditText.this.MIN || X8FixedEditText.this.MAX < value) { X8FixedEditText.this.listener.onError(X8FixedEditText.this, 1, null); } else { X8FixedEditText.this.listener.onInputChanged(X8FixedEditText.this.getId(), value); } } catch (Exception e) { X8FixedEditText.this.listener.onError(X8FixedEditText.this, 3, e.getMessage()); } } X8FixedEditText.this.hintKeyBoard(); return true; } }); }
Example #8
Source File: HttpAuthenticationDialogBuilder.java From focus-android with Mozilla Public License 2.0 | 6 votes |
public void createDialog() { LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.dialog_http_auth, null); usernameTextView = view.findViewById(R.id.httpAuthUsername); passwordTextView = view.findViewById(R.id.httpAuthPassword); passwordTextView.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { dialog.getButton(AlertDialog.BUTTON_POSITIVE).performClick(); return true; } return false; } }); buildDialog(view); }
Example #9
Source File: EditTextUtil.java From RxAndroidBootstrap with Apache License 2.0 | 5 votes |
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; }
Example #10
Source File: FriendAddActivity.java From yiim_v2 with GNU General Public License v2.0 | 5 votes |
@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; } }); }
Example #11
Source File: JieEditTextDel.java From AndJie with GNU General Public License v2.0 | 5 votes |
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { for (OnEditorActionListener l : mOnEditorActionListener) { l.onEditorAction(v, actionId, event); return true; } return false; }
Example #12
Source File: PickupSipUri.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@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); }
Example #13
Source File: EditText.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void setOnEditorActionListener(OnEditorActionListener listener) { ((JTextField)this.component).addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { listener.onEditorAction(EditText.this, 0, new KeyEvent()); } }); }
Example #14
Source File: EditText.java From BotLibre with Eclipse Public License 1.0 | 5 votes |
public void setOnEditorActionListener(OnEditorActionListener listener) { ((JTextField)this.component).addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent arg0) { listener.onEditorAction(EditText.this, 0, new KeyEvent()); } }); }
Example #15
Source File: PassphraseCreationDialogFragment.java From 365browser with Apache License 2.0 | 5 votes |
@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; }
Example #16
Source File: PinActivity.java From budget-envelopes with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); Intent i = getIntent(); if (i != null && "com.notriddle.budget.LOCK".equals(i.getAction())) { lock(); } else if (mPrefs.getString("com.notriddle.budget.pin", "").equals("") || mPrefs.getBoolean("com.notriddle.budget.unlocked", false)) { finishSuccessful(); } else { Parcelable nextActivity = i == null ? null : i.getParcelableExtra("com.notriddle.budget.NEXT_ACTIVITY"); mNextActivity = (PendingIntent) nextActivity; Log.d("Budget", "mNextActivity="+mNextActivity); setContentView(R.layout.activity_pin); mPin = (EditText) findViewById(R.id.pin); mPin.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { check(); return true; } return false; } }); } }
Example #17
Source File: ConsoleActivity.java From Android-SerialPort-API with Apache License 2.0 | 5 votes |
@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; } }); }
Example #18
Source File: MainActivity.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getActionBar(); Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); actionBar. setBackgroundDrawable(new BitmapDrawable(getResources(), b)); // add the custom view to the action bar actionBar.setCustomView(R.layout.actionbar_view); EditText search = (EditText) actionBar.getCustomView().findViewById( R.id.searchfield); search.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { Toast.makeText(MainActivity.this, "Search triggered", Toast.LENGTH_LONG).show(); return false; } }); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME); }
Example #19
Source File: EditTextUtil.java From MVPAndroidBootstrap with Apache License 2.0 | 5 votes |
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; }
Example #20
Source File: PassphraseCreationDialogFragment.java From AndroidChromium with Apache License 2.0 | 5 votes |
@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; }
Example #21
Source File: PassphraseCreationDialogFragment.java From delion with Apache License 2.0 | 5 votes |
@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; }
Example #22
Source File: LoginActivity.java From CameraV with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); packageName = this.getPackageName(); setContentView(R.layout.activity_login); rootView = findViewById(R.id.llRoot); boolean prefStealthIcon = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("prefStealthIcon",false); if (prefStealthIcon) { ImageView iv = (ImageView)findViewById(R.id.loginLogo); iv.setImageResource(R.drawable.ic_launcher_alt); } password = (EditText) findViewById(R.id.login_password); password.setImeOptions(EditorInfo.IME_ACTION_DONE); password.setOnEditorActionListener(new OnEditorActionListener () { @Override public boolean onEditorAction(TextView arg0, 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) { doLogin (); } return true; } }); /** commit = (Button) findViewById(R.id.login_commit); commit.setOnClickListener(this); */ waiter = (ProgressBar) findViewById(R.id.login_waiter); checkForCrashes(); checkForUpdates(); }
Example #23
Source File: LockScreenActivity.java From CameraV with GNU General Public License v3.0 | 4 votes |
private void promptPassphrase() { mViewCreatePassphrase.setVisibility(View.GONE); mViewEnterPassphrase.setVisibility(View.VISIBLE); /* mBtnOpen = (Button) findViewById(R.id.btnOpen); mBtnOpen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mEnterPassphrase.getText().toString().length() == 0) return; // Check passphrase try { mCacheWord.setPassphrase(mEnterPassphrase.getText().toString().toCharArray()); } catch (GeneralSecurityException e) { mEnterPassphrase.setText(""); Log.e(TAG, "Cacheword pass verification failed: " + e.getMessage()); return; } } });*/ mEnterPassphrase.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); Handler threadHandler = new Handler(); imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver( threadHandler) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); if (mEnterPassphrase.getText().toString().length() == 0) return; // Check passphrase try { mCacheWord.setPassphrase(mEnterPassphrase.getText().toString().toCharArray()); } catch (GeneralSecurityException e) { mEnterPassphrase.setText(""); Log.e(TAG, "Cacheword pass verification failed: " + e.getMessage()); return; } } }); return true; } return false; } }); }
Example #24
Source File: RMBTSyncEnterCodeFragment.java From open-rmbt with Apache License 2.0 | 4 votes |
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { view = inflater.inflate(R.layout.sync_enter_code, container, false); syncButton = (Button) view.findViewById(R.id.button); overlay = (LinearLayout) view.findViewById(R.id.overlay); codeField = (EditText) view.findViewById(R.id.code); final RMBTSyncEnterCodeFragment tmp = this; listener = new OnClickListener() { @Override public void onClick(final View v) { final String syncCode = codeField.getText().toString().toUpperCase(Locale.US); if (syncCode.length() == 12) { if (syncTask == null || syncTask != null || syncTask.isCancelled()) { overlay.setVisibility(View.VISIBLE); overlay.setClickable(true); overlay.bringToFront(); syncButton.setOnClickListener(null); // codeField.setClickable(false); syncTask = new CheckSyncTask(getActivity()); syncTask.setEndTaskListener(tmp); syncTask.execute(syncCode); } } else codeField.setError(getActivity().getString(R.string.sync_enter_code_length)); } }; codeField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { listener.onClick(v); return true; } }); syncButton.setOnClickListener(listener); return view; }
Example #25
Source File: JieEditTextDel.java From AndJie with GNU General Public License v2.0 | 4 votes |
public void addOnEditorActionListener(OnEditorActionListener l) { mOnEditorActionListener.add(l); }
Example #26
Source File: LockScreenActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 4 votes |
private void promptPassphrase() { mViewCreatePassphrase.setVisibility(View.GONE); mViewEnterPassphrase.setVisibility(View.VISIBLE); mEnterPassphrase.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); Handler threadHandler = new Handler(); imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver( threadHandler) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); if (mEnterPassphrase.getText().toString().length() == 0) return; // Check passphrase try { char[] passphrase = mEnterPassphrase.getText().toString().toCharArray(); mCacheWord.setPassphrase(passphrase); } catch (Exception e) { mEnterPassphrase.setText(""); // TODO implement try again and wipe if fail Log.e(TAG, "Cacheword pass verification failed: " + e.getMessage()); return; } } }); return true; } return false; } }); }
Example #27
Source File: EditorTextField.java From delion with Apache License 2.0 | 4 votes |
public EditorTextField(Context context, final EditorFieldModel fieldModel, OnEditorActionListener actionlistener, PhoneNumberFormattingTextWatcher formatter, PaymentRequestObserverForTest observer) { super(context); assert fieldModel.getInputTypeHint() != EditorFieldModel.INPUT_TYPE_HINT_DROPDOWN; mEditorFieldModel = fieldModel; mObserverForTest = observer; // Build up the label. Required fields are indicated by appending a '*'. CharSequence label = fieldModel.getLabel(); if (fieldModel.isRequired()) label = label + REQUIRED_FIELD_INDICATOR; setHint(label); // The EditText becomes a child of this class. The TextInputLayout manages how it looks. LayoutInflater.from(context).inflate(R.layout.payments_request_editor_textview, this, true); mInput = (AutoCompleteTextView) findViewById(R.id.text_view); mInput.setText(fieldModel.getValue()); mInput.setOnEditorActionListener(actionlistener); // Validate the field when the user de-focuses it. mInput.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { mHasFocusedAtLeastOnce = true; } else if (mHasFocusedAtLeastOnce) { // Show no errors until the user has already tried to edit the field once. updateDisplayedError(!mEditorFieldModel.isValid()); } } }); // Update the model as the user edits the field. mInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { fieldModel.setValue(s.toString()); updateDisplayedError(false); if (mObserverForTest != null) { mObserverForTest.onPaymentRequestEditorTextUpdate(); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) {} }); // Display any autofill suggestions. if (fieldModel.getSuggestions() != null && !fieldModel.getSuggestions().isEmpty()) { mInput.setAdapter(new ArrayAdapter<CharSequence>(getContext(), android.R.layout.simple_spinner_dropdown_item, fieldModel.getSuggestions())); mInput.setThreshold(0); } switch (fieldModel.getInputTypeHint()) { case EditorFieldModel.INPUT_TYPE_HINT_PHONE: mInput.setInputType(InputType.TYPE_CLASS_PHONE); break; case EditorFieldModel.INPUT_TYPE_HINT_EMAIL: mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); break; case EditorFieldModel.INPUT_TYPE_HINT_STREET_LINES: // TODO(rouslan): Provide a hint to the keyboard that the street lines are // likely to have numbers. mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS); break; case EditorFieldModel.INPUT_TYPE_HINT_PERSON_NAME: mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_VARIATION_PERSON_NAME); break; case EditorFieldModel.INPUT_TYPE_HINT_REGION: mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS); break; case EditorFieldModel.INPUT_TYPE_HINT_ALPHA_NUMERIC: // Intentionally fall through. // TODO(rouslan): Provide a hint to the keyboard that postal code and sorting // code are likely to have numbers. default: mInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS); break; } }
Example #28
Source File: LogcatActivity.java From javaide with GNU General Public License v3.0 | 4 votes |
private void showAddFilterDialog(final FilterAdapter filterAdapter) { // show a popup to add a new filter text LayoutInflater inflater = getLayoutInflater(); @SuppressLint("InflateParams") final AutoCompleteTextView editText = (AutoCompleteTextView) inflater.inflate(R.layout.dialog_new_filter, null, false); // show suggestions as the user types List<String> suggestions = new ArrayList<>(mSearchSuggestionsSet); SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>( this, R.layout.list_item_dropdown, suggestions); editText.setAdapter(suggestionAdapter); final MaterialDialog alertDialog = new MaterialDialog.Builder(this) .title(R.string.add_filter) .positiveText(android.R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { handleNewFilterText(editText.getText().toString(), filterAdapter); dialog.dismiss(); } }) .negativeText(android.R.string.cancel) .customView(editText, true) .build(); // when 'Done' is clicked (i.e. enter button), do the same as when "OK" is clicked editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { // dismiss soft keyboard handleNewFilterText(editText.getText().toString(), filterAdapter); alertDialog.dismiss(); return true; } return false; } }); alertDialog.show(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, 0); }
Example #29
Source File: LogcatActivity.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
private void showAddFilterDialog(final FilterAdapter filterAdapter) { // show a popup to add a new filter text LayoutInflater inflater = getLayoutInflater(); @SuppressLint("InflateParams") final AutoCompleteTextView editText = (AutoCompleteTextView) inflater.inflate(R.layout.dialog_new_filter, null, false); // show suggestions as the user types List<String> suggestions = new ArrayList<>(mSearchSuggestionsSet); SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>( this, R.layout.list_item_dropdown, suggestions); editText.setAdapter(suggestionAdapter); final MaterialDialog alertDialog = new MaterialDialog.Builder(this) .title(R.string.add_filter) .positiveText(android.R.string.ok) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { handleNewFilterText(editText.getText().toString(), filterAdapter); dialog.dismiss(); } }) .negativeText(android.R.string.cancel) .customView(editText, true) .build(); // when 'Done' is clicked (i.e. enter button), do the same as when "OK" is clicked editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { // dismiss soft keyboard handleNewFilterText(editText.getText().toString(), filterAdapter); alertDialog.dismiss(); return true; } return false; } }); alertDialog.show(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(editText, 0); }
Example #30
Source File: LockScreenActivity.java From zom-android-matrix with Apache License 2.0 | 4 votes |
private void promptPassphrase() { mViewCreatePassphrase.setVisibility(View.GONE); mViewEnterPassphrase.setVisibility(View.VISIBLE); mEnterPassphrase.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL || actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); Handler threadHandler = new Handler(); imm.hideSoftInputFromWindow(v.getWindowToken(), 0, new ResultReceiver( threadHandler) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { super.onReceiveResult(resultCode, resultData); if (mEnterPassphrase.getText().toString().length() == 0) return; // Check passphrase try { char[] passphrase = mEnterPassphrase.getText().toString().toCharArray(); mCacheWord.setPassphrase(passphrase); } catch (Exception e) { mEnterPassphrase.setText(""); // TODO implement try again and wipe if fail Log.e(TAG, "Cacheword pass verification failed: " + e.getMessage()); return; } } }); return true; } return false; } }); }