List of usage examples for android.widget TextView focusSearch
public View focusSearch(@FocusRealDirection int direction)
From source file:org.chromium.chrome.browser.payments.ui.EditorView.java
/** * Builds the editor view.//from w ww . ja v a 2 s . co m * * @param activity The activity on top of which the UI should be displayed. * @param observerForTest Optional event observer for testing. */ public EditorView(Activity activity, PaymentRequestObserverForTest observerForTest) { super(activity, R.style.FullscreenWhite); // Sets transparent background for animating content view. getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mContext = activity; mObserverForTest = observerForTest; mHandler = new Handler(); mEditorActionListener = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { mDoneButton.performClick(); return true; } else if (actionId == EditorInfo.IME_ACTION_NEXT) { View next = v.focusSearch(View.FOCUS_FORWARD); if (next != null) { next.requestFocus(); return true; } } return false; } }; mHalfRowMargin = activity.getResources().getDimensionPixelSize(R.dimen.payments_section_large_spacing); mFieldViews = new ArrayList<>(); mEditableTextFields = new ArrayList<>(); mDropdownFields = new ArrayList<>(); final Pattern cardNumberPattern = Pattern.compile("^[\\d- ]*$"); mCardNumberInputFilter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // Accept deletions. if (start == end) return null; // Accept digits, "-", and spaces. if (cardNumberPattern.matcher(source.subSequence(start, end)).matches()) { return null; } // Reject everything else. return ""; } }; mCardNumberFormatter = new CreditCardNumberFormattingTextWatcher(); new AsyncTask<Void, Void, PhoneNumberFormattingTextWatcher>() { @Override protected PhoneNumberFormattingTextWatcher doInBackground(Void... unused) { return new PhoneNumberFormattingTextWatcher(); } @Override protected void onPostExecute(PhoneNumberFormattingTextWatcher result) { mPhoneFormatter = result; if (mPhoneInput != null) { mPhoneInput.addTextChangedListener(mPhoneFormatter); } } }.execute(); }
From source file:org.cm.podd.report.activity.ReportActivity.java
@Override public boolean onSoftKeyAction(TextView view, int actionId, KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_NEXT: Log.d(TAG, "action NEXT"); View nextTextView = view.focusSearch(View.FOCUS_DOWN); if (nextTextView != null) { nextTextView.requestFocus(); if (!(nextTextView instanceof EditText)) { hideKeyboard();//from www. j a v a 2s .c o m } return true; } case EditorInfo.IME_ACTION_DONE: Log.d(TAG, "action DONE"); nextScreen(); hideKeyboard(); return true; } return false; }