android.view.inputmethod.EditorInfo#IME_ACTION_NEXT源码实例Demo

下面列出了android.view.inputmethod.EditorInfo#IME_ACTION_NEXT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CodenameOne   文件: CodenameOneInputConnection.java
@Override
public boolean performEditorAction(int actionCode) {
    if (Display.isInitialized() && Display.getInstance().getCurrent() != null) {
        Component txtCmp = Display.getInstance().getCurrent().getFocused();
        if (txtCmp != null && txtCmp instanceof TextField) {
            TextField t = (TextField) txtCmp;
            if (actionCode == EditorInfo.IME_ACTION_DONE) {
                Display.getInstance().setShowVirtualKeyboard(false);
            } else if (actionCode == EditorInfo.IME_ACTION_NEXT) {
                Display.getInstance().setShowVirtualKeyboard(false);
                txtCmp.getNextFocusDown().requestFocus();
            }
        }
    }

    return super.performEditorAction(actionCode);
}
 
源代码2 项目: JumpGo   文件: BrowserActivity.java
@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
    // hide the keyboard and search the web when the enter key
    // button is pressed
    if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
        || actionId == EditorInfo.IME_ACTION_NEXT
        || actionId == EditorInfo.IME_ACTION_SEND
        || actionId == EditorInfo.IME_ACTION_SEARCH
        || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
        searchTheWeb(mSearch.getText().toString());
        final LightningView currentView = mTabsManager.getCurrentTab();
        if (currentView != null) {
            currentView.requestFocus();
        }
        return true;
    }
    return false;
}
 
public static String imeActionName(final int imeOptions) {
    final int actionId = imeOptions & EditorInfo.IME_MASK_ACTION;
    switch (actionId) {
    case EditorInfo.IME_ACTION_UNSPECIFIED:
        return "actionUnspecified";
    case EditorInfo.IME_ACTION_NONE:
        return "actionNone";
    case EditorInfo.IME_ACTION_GO:
        return "actionGo";
    case EditorInfo.IME_ACTION_SEARCH:
        return "actionSearch";
    case EditorInfo.IME_ACTION_SEND:
        return "actionSend";
    case EditorInfo.IME_ACTION_NEXT:
        return "actionNext";
    case EditorInfo.IME_ACTION_DONE:
        return "actionDone";
    case EditorInfo.IME_ACTION_PREVIOUS:
        return "actionPrevious";
    default:
        return "actionUnknown(" + actionId + ")";
    }
}
 
源代码4 项目: Cirrus_depricated   文件: AuthenticatorActivity.java
/**
 *  Called when the 'action' button in an IME is pressed ('enter' in software keyboard).
 * 
 *  Used to trigger the authentication check when the user presses 'enter' after writing the 
 *  password, or to throw the server test when the only field on screen is the URL input field.
 */
@Override
public boolean onEditorAction(TextView inputField, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE && inputField != null && 
            inputField.equals(mPasswordInput)) {
        if (mOkButton.isEnabled()) {
            mOkButton.performClick();
        }

    } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && 
            inputField.equals(mHostUrlInput)) {
        if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
                equals(mAuthTokenType)) {
            checkOcServer();
        }
    }
    return false;   // always return false to grant that the software keyboard is hidden anyway
}
 
源代码5 项目: dhis2-android-datacapture   文件: FieldAdapter.java
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    final TextView view = v;
    if(actionId == EditorInfo.IME_ACTION_NEXT) {
        int position= mListView.getPositionForView(v);
        mListView.smoothScrollToPosition(position+1);
        mListView.postDelayed(new Runnable() {
            public void run() {
                TextView nextField = (TextView)view.focusSearch(View.FOCUS_DOWN);
                if(nextField != null) {
                    nextField.requestFocus();
                }
            }
        }, 200);
        return true;
    }
    return false;
}
 
源代码6 项目: Xndroid   文件: BrowserActivity.java
@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
    // hide the keyboard and search the web when the enter key
    // button is pressed
    if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
        || actionId == EditorInfo.IME_ACTION_NEXT
        || actionId == EditorInfo.IME_ACTION_SEND
        || actionId == EditorInfo.IME_ACTION_SEARCH
        || (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
        searchTheWeb(mSearch.getText().toString());
        final LightningView currentView = mTabsManager.getCurrentTab();
        if (currentView != null) {
            currentView.requestFocus();
        }
        return true;
    }
    return false;
}
 
public static String imeActionName(final int imeOptions) {
    final int actionId = imeOptions & EditorInfo.IME_MASK_ACTION;
    switch (actionId) {
    case EditorInfo.IME_ACTION_UNSPECIFIED:
        return "actionUnspecified";
    case EditorInfo.IME_ACTION_NONE:
        return "actionNone";
    case EditorInfo.IME_ACTION_GO:
        return "actionGo";
    case EditorInfo.IME_ACTION_SEARCH:
        return "actionSearch";
    case EditorInfo.IME_ACTION_SEND:
        return "actionSend";
    case EditorInfo.IME_ACTION_NEXT:
        return "actionNext";
    case EditorInfo.IME_ACTION_DONE:
        return "actionDone";
    case EditorInfo.IME_ACTION_PREVIOUS:
        return "actionPrevious";
    default:
        return "actionUnknown(" + actionId + ")";
    }
}
 
源代码8 项目: android-chromium   文件: AdapterInputConnection.java
/**
 * @see BaseInputConnection#performEditorAction(int)
 */
@Override
public boolean performEditorAction(int actionCode) {
    if (DEBUG) Log.w(TAG, "performEditorAction [" + actionCode + "]");
    if (actionCode == EditorInfo.IME_ACTION_NEXT) {
        restartInput();
        // Send TAB key event
        long timeStampMs = System.currentTimeMillis();
        mImeAdapter.sendSyntheticKeyEvent(
                ImeAdapter.sEventTypeRawKeyDown, timeStampMs, KeyEvent.KEYCODE_TAB, 0);
    } else {
        mImeAdapter.sendKeyEventWithKeyCode(KeyEvent.KEYCODE_ENTER,
                KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE
                | KeyEvent.FLAG_EDITOR_ACTION);
    }
    return true;
}
 
源代码9 项目: IdeaTrackerPlus   文件: MainActivity.java
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

    if (actionId == EditorInfo.IME_ACTION_GO
            || actionId == EditorInfo.IME_ACTION_DONE
            || actionId == EditorInfo.IME_ACTION_NEXT
            || actionId == EditorInfo.IME_ACTION_SEND
            || actionId == EditorInfo.IME_ACTION_SEARCH
            || actionId == EditorInfo.IME_NULL) {

        switch ((int) v.getTag()) {
            case 1:
                mNoteField.requestFocus();
                break;

            case 2:
                sendIdeaFromDialog();
                break;

            default:
                break;
        }
        return true;
    }
    return false;
}
 
源代码10 项目: ticdesign   文件: DatePicker.java
/**
 * Sets the IME options for a spinner based on its ordering.
 *
 * @param spinner The spinner.
 * @param spinnerCount The total spinner count.
 * @param spinnerIndex The index of the given spinner.
 */
private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIndex) {
    final int imeOptions;
    if (spinnerIndex < spinnerCount - 1) {
        imeOptions = EditorInfo.IME_ACTION_NEXT;
    } else {
        imeOptions = EditorInfo.IME_ACTION_DONE;
    }
    TextView input = (TextView) spinner.findViewById(R.id.numberpicker_input);
    input.setImeOptions(imeOptions);
}
 
源代码11 项目: java-n-IDE-for-Android   文件: LatinKeyboard.java
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    int valnorm = KeyEvent.KEYCODE_ENTER;

    switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            mEnterKey.codes = TERMINAL_ENTER;
            break;
    }
}
 
源代码12 项目: DateTimePicker   文件: DatePickerSpinnerDelegate.java
/**
 * Sets the IME options for a spinner based on its ordering.
 *
 * @param spinner      The spinner.
 * @param spinnerCount The total spinner count.
 * @param spinnerIndex The index of the given spinner.
 */
private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIndex) {
    final int imeOptions;
    if (spinnerIndex < spinnerCount - 1) {
        imeOptions = EditorInfo.IME_ACTION_NEXT;
    } else {
        imeOptions = EditorInfo.IME_ACTION_DONE;
    }
    TextView input = (TextView) spinner.findViewById(R.id.numberpicker_input);
    input.setImeOptions(imeOptions);
}
 
源代码13 项目: kboard   文件: KBoard.java
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
源代码14 项目: kboard   文件: KBoard.java
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
源代码15 项目: IdeaTrackerPlus   文件: RecyclerOnClickListener.java
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO
            || actionId == EditorInfo.IME_ACTION_DONE
            || actionId == EditorInfo.IME_ACTION_NEXT
            || actionId == EditorInfo.IME_ACTION_SEND
            || actionId == EditorInfo.IME_ACTION_SEARCH
            || actionId == EditorInfo.IME_NULL) {
        mNoteField.requestFocus();
    }
    return true;
}
 
源代码16 项目: bither-android   文件: EntryKeyboardView.java
private void configureDoneButton() {
    View currentFocusView = getRootView().findFocus();
    if (currentFocusView == null) {
        return;
    }
    if (currentFocusView instanceof EditText) {
        EditText currentFocusEt = (EditText) currentFocusView;
        if (!Utils.isEmpty(currentFocusEt.getImeActionLabel() == null ? null :
                currentFocusEt.getImeActionLabel().toString())) {
            setEnterKeyText(currentFocusEt.getImeActionLabel());
        } else if (currentFocusEt.getImeActionId() > 0) {
            switch (currentFocusEt.getImeActionId()) {
                case EditorInfo.IME_ACTION_DONE:
                case EditorInfo.IME_ACTION_GO:
                case EditorInfo.IME_ACTION_SEND:
                    setEnterKeyText(getResources().getString(R.string.password_keyboard_done));
                    break;
                case EditorInfo.IME_ACTION_NEXT:
                    setEnterKeyText(getResources().getString(R.string.password_keyboard_next));
                    break;
                default:
                    break;
            }
        } else {
            View nextFocusView = currentFocusEt.focusSearch(View.FOCUS_DOWN);
            if (nextFocusView != null) {
                setEnterKeyText(getResources().getString(R.string.password_keyboard_next));
            } else {
                setEnterKeyText(getResources().getString(R.string.password_keyboard_done));
            }
        }
        EntryKeyboard keyboard = (EntryKeyboard) getKeyboard();
        invalidateKey(keyboard.getEnterKeyIndex());
    }
}
 
源代码17 项目: android-chromium   文件: AdapterInputConnection.java
@VisibleForTesting
AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) {
    super(view, true);
    mInternalView = view;
    mImeAdapter = imeAdapter;
    mImeAdapter.setInputConnection(this);
    mSingleLine = true;
    outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
            | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;

    if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeText) {
        // Normal text field
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTextArea ||
            imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeContentEditable) {
        // TextArea or contenteditable.
        outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
                | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
        mSingleLine = false;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypePassword) {
        // Password
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeSearch) {
        // Search
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_SEARCH;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeUrl) {
        // Url
        // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
        // exclude it for now.
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeEmail) {
        // Email
        outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel) {
        // Telephone
        // Number and telephone do not have both a Tab key and an
        // action in default OSK, so set the action to NEXT
        outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNumber) {
        // Number
        outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
                | InputType.TYPE_NUMBER_VARIATION_NORMAL;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
    }
    outAttrs.initialSelStart = imeAdapter.getInitialSelectionStart();
    outAttrs.initialSelEnd = imeAdapter.getInitialSelectionEnd();
    mLastUpdateSelectionStart = imeAdapter.getInitialSelectionStart();
    mLastUpdateSelectionEnd = imeAdapter.getInitialSelectionEnd();
}
 
源代码18 项目: AndroidChromium   文件: EditorView.java
/**
 * Builds the editor view.
 *
 * @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);
    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();
}
 
源代码19 项目: LokiBoard-Android-Keylogger   文件: KeyboardId.java
public boolean navigateNext() {
    return (mEditorInfo.imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0
            || imeAction() == EditorInfo.IME_ACTION_NEXT;
}
 
源代码20 项目: px-android   文件: PayerInformationActivity.java
private boolean isNextKey(final int actionId, final KeyEvent event) {
    return actionId == EditorInfo.IME_ACTION_NEXT ||
        (event != null && event.getAction() == KeyEvent.ACTION_DOWN &&
            event.getKeyCode() == KeyEvent.KEYCODE_ENTER);
}