gpt4 book ai didi

java - EditView 在单击时执行操作

转载 作者:行者123 更新时间:2023-12-01 23:39:08 26 4
gpt4 key购买 nike

我有一个 EditView 并且我添加了:

android:imeActionLabel="Go"

这在键盘中显示“Go”按钮,但我不知道当用户单击“Go”按钮时如何执行操作。

有没有什么解决办法,如果有的话我该怎么办?

最佳答案

EditText.OnEditorActionListener 就是您正在寻找的内容,API 文档可以在 here 找到。将为 GO 按钮调用的操作是 EditorInfo.IME_ACTION_GO。我在下面提供了一个简短的示例。

editText.setOnEditorActionListener(new OnEditorActionListener()
{
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
if(actionId==EditorInfo.IME_ACTION_GO)
{
//Handle go button pressed
}
return false;
}
});

关于java - EditView 在单击时执行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18219340/

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