0

我是 Kotlin 的新手,我被困在一个特定的点上。我的一个 UI 片段中有这个 EditText:

            <EditText
            android:id="@+id/editText3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="100dp"
            android:ems="10"
            android:gravity="start|top"
            android:imeOptions="actionSend"
            android:inputType="text" />

我现在如何通过单击键盘上的发送按钮来调用函数。任何人都可以让我知道我该把代码放在哪里。

非常感谢!

4

1 回答 1

0

这种写在kotlin中的方式

editText3.setOnEditorActionListener { textView , actionId, event ->
        if(actionId == EditorInfo.IME_ACTION_SEND){
            //doSomething()
            true
        } else {
            false
        }
    }
于 2019-11-11T20:39:58.600 回答