suragch / mongol-library

A library to allow vertical script Mongolian in Android apps
MIT License
58 stars 17 forks source link

MongolEditText 如何监听回车按键 #4

Closed L-X-J closed 5 years ago

L-X-J commented 5 years ago

我在用MongolEditText做搜索功框,但是我没办法监听到回车按键,我们的需求是回车就可以搜索, 如果需要改源码,我应该在哪里改

suragch commented 5 years ago

应该可以用mongolEditText.addTextChangedListener(TextWatcher watcher),然后监听回车。

参考以下的有关内容:

L-X-J commented 5 years ago

蒙文是不是从右往左的?

L-X-J commented 5 years ago

谢谢大佬

addTextChangedListener(object :TextWatcher{
            override fun afterTextChanged(s: Editable?) {

            }

            override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
            }

            override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
                if (s?.contains("\n") == true) {
                         //do something
                }
            }
        })