Триггер OneditorAction слушатель не работаетAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Триггер OneditorAction слушатель не работает

Сообщение Anonymous »

Я пытаюсь передать OneDitorActionListener на мой взгляд. Тем не менее, OneDitorActionListener не запускается. < /P>
class WMScanEmpfaengerFragment : TransactionNavigationFragment() {
private lateinit var binding: FragmentScanEmpfaengerBinding
override fun getViewModelClass() = WMScanEmpfaengerViewModel::class

override fun getContentLayoutResId() = R.layout.fragment_scan_empfaenger

override fun isTransactionRoot() = true

override var barcodeScannerEnabled = true

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding = FragmentScanEmpfaengerBinding.inflate(layoutInflater)
binding.scaninputView.setOnEditorActionListener( OnEditorActionListener { v, actionId, event ->
if (event != null && event.keyCode == KeyEvent.KEYCODE_ENTER || actionId == EditorInfo.IME_ACTION_DONE && v.text.isNotBlank()) {
setEmpfaenger(v.text.toString().trim())
true
}
false

})
< /code>
фрагмент < /p>
class ScanInputView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
private val binding: ViewScaninputBinding = ViewScaninputBinding.inflate(LayoutInflater.from(context), this)

init {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ScanInputView)
val hint = typedArray.getString(R.styleable.ScanInputView_hint)
val imeNext = typedArray.getBoolean(R.styleable.ScanInputView_imeNext, false)
typedArray.recycle()

binding.inputId.showSoftInputOnFocus = false
binding.inputId.addTextChangedListener(AppUtils.onTextChanged { binding.inputLayoutId.error = null })

setHint(hint)
if (imeNext)
binding.inputId.imeOptions = EditorInfo.IME_ACTION_NEXT

binding.btnKeyboard.setOnClickListener {
val keyboard = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
if (!binding.inputId.hasFocus()) {
binding.inputId.requestFocus()
moveCursorToEnd()
}
keyboard.showSoftInput(binding.inputId, 0)
}

}

...

fun setOnEditorActionListener(editorActionListener: TextView.OnEditorActionListener) {
binding.inputId.setOnEditorActionListener(editorActionListener)

}
...

< /code>
Просмотр < /p>













< /code>
xml view < /p>
Можете ли вы мне помочь? Спасибо
Как только я нажимаю Enter, он должен вызвать метод setempfaenger.
У меня есть разные способы переписать привязку.
Я изменяю Android: Imeoptions = "ActionDone" на Android: imeoptions = "Actiongo"
.>

Подробнее здесь: https://stackoverflow.com/questions/796 ... oesnt-work
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»