Java Code Examples for com.google.android.material.textfield.TextInputEditText#setOnEditorActionListener()

The following examples show how to use com.google.android.material.textfield.TextInputEditText#setOnEditorActionListener() . 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: AlarmDescriptionStep.java    From VerticalStepperForm with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
protected View createStepContentLayout() {

    // We create this step view programmatically
    alarmDescriptionEditText = new TextInputEditText(getContext());
    alarmDescriptionEditText.setHint(R.string.form_hint_description);
    alarmDescriptionEditText.setSingleLine(true);
    alarmDescriptionEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            getFormView().goToNextStep(true);
            return false;
        }
    });

    return alarmDescriptionEditText;
}
 
Example 2
Source File: BindingAdapters.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
@BindingAdapter("editorAction")
public static void setEditorAction(final TextInputEditText editText, final TextView.OnEditorActionListener listener) {
    editText.setOnEditorActionListener(listener);
}
 
Example 3
Source File: SearchFragment.java    From ArchPackages with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FragmentSearchBinding fragmentSearchBinding = FragmentSearchBinding.inflate(inflater, container, false);
    textInputLayout = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputLayout;
    // keywords radio group
    radioGroupKeywords = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsRadioGroup;
    // repo check boxes
    checkBoxRepoCore = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCore;
    checkBoxRepoExtra = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoExtra;
    checkBoxRepoTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoTesting;
    checkBoxRepoMultilib = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoMultilib;
    checkBoxRepoMultilibTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoMultilibTesting;
    checkBoxRepoCommunity = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCommunity;
    checkBoxRepoCommunityTesting = fragmentSearchBinding.fragmentSearchRepoLayout.searchCheckBoxRepoCommunityTesting;
    // arch check boxes
    checkBoxArchAny = fragmentSearchBinding.fragmentSearchArchLayout.searchCheckBoxArchAny;
    checkBoxArchX84_64 = fragmentSearchBinding.fragmentSearchArchLayout.searchCheckBoxArchX8664;
    // flagged radio buttons
    radioGroupFlag = fragmentSearchBinding.fragmentSearchFlagLayout.searchFlagRadioGroup;
    // search ime action
    TextInputEditText textInputEditText = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputEditText;
    textInputEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    textInputEditText.setOnEditorActionListener((editTextView, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            if (searchFragmentCallback != null) {
                searchFragmentCallback.onSearchFragmentCallbackOnFabClicked(
                        getKeywordsParameter(),
                        getQuery(),
                        getListRepo(),
                        getListArch(),
                        getFlagged());
            }
            InputMethodManager inputMethodManager = (InputMethodManager) editTextView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            if (inputMethodManager != null)
                inputMethodManager.hideSoftInputFromWindow(editTextView.getWindowToken(), 0);
            return true;
        }
        return false;
    });
    return fragmentSearchBinding.getRoot();
}
 
Example 4
Source File: CardForm.java    From android-card-form with MIT License 4 votes vote down vote up
/**
 * Sets up the card form for display to the user using the values provided in {@link CardForm#cardRequired(boolean)},
 * {@link CardForm#expirationRequired(boolean)}, ect. If {@link CardForm#setup(AppCompatActivity)} is not called,
 * the form will not be visible.
 *
 * @param activity Used to set {@link android.view.WindowManager.LayoutParams#FLAG_SECURE} to prevent screenshots
 */
public void setup(AppCompatActivity activity) {
    mCardScanningFragment = (CardScanningFragment)activity
            .getSupportFragmentManager()
            .findFragmentByTag(CardScanningFragment.TAG);

    if (mCardScanningFragment != null) {
        mCardScanningFragment.setCardForm(this);
    }

    activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
            WindowManager.LayoutParams.FLAG_SECURE);

    boolean cardHolderNameVisible = mCardholderNameStatus != FIELD_DISABLED;
    boolean isDarkBackground = ViewUtils.isDarkBackground(activity);
    mCardholderNameIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_cardholder_name_dark: R.drawable.bt_ic_cardholder_name);
    mCardNumberIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_card_dark : R.drawable.bt_ic_card);
    mPostalCodeIcon.setImageResource(isDarkBackground ? R.drawable.bt_ic_postal_code_dark : R.drawable.bt_ic_postal_code);
    mMobileNumberIcon.setImageResource(isDarkBackground? R.drawable.bt_ic_mobile_number_dark : R.drawable.bt_ic_mobile_number);

    mExpiration.useDialogForExpirationDateEntry(activity, true);

    setViewVisibility(mCardholderNameIcon,  cardHolderNameVisible);
    setFieldVisibility(mCardholderName, cardHolderNameVisible);
    setViewVisibility(mCardNumberIcon, mCardNumberRequired);
    setFieldVisibility(mCardNumber, mCardNumberRequired);
    setFieldVisibility(mExpiration, mExpirationRequired);
    setFieldVisibility(mCvv, mCvvRequired);
    setViewVisibility(mPostalCodeIcon, mPostalCodeRequired);
    setFieldVisibility(mPostalCode, mPostalCodeRequired);
    setViewVisibility(mMobileNumberIcon, mMobileNumberRequired);
    setFieldVisibility(mCountryCode, mMobileNumberRequired);
    setFieldVisibility(mMobileNumber, mMobileNumberRequired);
    setViewVisibility(mMobileNumberExplanation, mMobileNumberRequired);
    setViewVisibility(mSaveCardCheckBox, mSaveCardCheckBoxVisible);

    TextInputEditText editText;
    for (int i = 0; i < mVisibleEditTexts.size(); i++) {
        editText = mVisibleEditTexts.get(i);
        if (i == mVisibleEditTexts.size() - 1) {
            editText.setImeOptions(EditorInfo.IME_ACTION_GO);
            editText.setImeActionLabel(mActionLabel, EditorInfo.IME_ACTION_GO);
            editText.setOnEditorActionListener(this);
        } else {
            editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            editText.setImeActionLabel(null, EditorInfo.IME_ACTION_NONE);
            editText.setOnEditorActionListener(null);
        }
    }

    mSaveCardCheckBox.setInitiallyChecked(mSaveCardCheckBoxChecked);

    setVisibility(VISIBLE);
}