gpt4 book ai didi

android - 软键盘从 EditText 发送文本到程序

转载 作者:搜寻专家 更新时间:2023-11-01 07:40:31 24 4
gpt4 key购买 nike

我认为我即将获得软键盘 IME_ACTION_SEND 的监听器。目标是执行另一个按钮的点击。它没有显示在此处的屏幕代码中,但“OnEditorActionListener()”在源代码编辑器中带有红色下划线并给出错误:

“new TextView.OnEditorActionListener(){} 类型必须实现继承的抽象方法 TextView.OnEditorActionListener.onEditorAction(TextView, int, KeyEvent)”,我以为我是。

“KeyEvent”关键字在编辑器中也是一个错误:“KeyEvent cannot be resolved to a type”。

可能是我在做(或没做)的蠢事。谢谢你的帮助。

        et1.setOnEditorActionListener(new OnEditorActionListener() { 
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
calculateButton.performClick();
}
return true;
}
});

最佳答案

您需要导入 KeyEvent 类,仅此而已:-)

import android.view.KeyEvent;

关于android - 软键盘从 EditText 发送文本到程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4411594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com