1

I want to pass values like EditText's imeOption and inputType to a custom view (which contains an EditText) using @BindingAdapter so it can be customizable from the view that will be using it.

Ideally this would go:

@JvmStatic
@BindingAdapter("customEditText:imeOptions")
fun setImeOption(view: CustomEditText, inputVariable: Int) {
    view.binding.editText.imeOptions = inputVariable
}

and in xml:

<CustomEditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    customEditText:imeOptions="@{actionDone}"/>

but actionDone cannot be resolved. It there any way to do this?

Note: CustomEditText does not extend EditText, it's just a LinearLayout which contains an EditText among other views

4
  • CustomEditText is textview? CustomEditText edit what kind of view? Commented Oct 2, 2020 at 12:49
  • @sasikumar edited, it's nothing related to edittext or textView Commented Oct 2, 2020 at 13:11
  • then why you want to customEditText:imeOptions="@{actionDone}" ? Commented Oct 2, 2020 at 13:27
  • CustomEditText contains an EditText among other views Commented Oct 2, 2020 at 13:29

1 Answer 1

1

Within the data tags, import the EditorInfo class:

<data>
    <import type="android.view.inputmethod.EditorInfo"/>
</data>

And set it like:

customEditText:imeOptions="@{EditorInfo.IME_ACTION_DONE}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.