EditView中执行的单击操作 [英] EditView perform an action on click
本文介绍了EditView中执行的单击操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 EditView中
我也补充道:
android:imeActionLabel="Go"
这是显示在键盘上的转到按钮,但我不知道如何当用户点击转到按钮执行操作。
This is showing "Go" button in keyboard, but I don't know how to perform an action when user clicks "Go" button.
有没有这方面有任何的解决方案,如果是我该怎么办呢?
Is there any solution about this, if yes how can I do it?
推荐答案
EditText.OnEditorActionListener
是你在找什么,API文档,可以发现的此处。将呼吁GO按钮的动作是 EditorInfo.IME_ACTION_GO
。我提供了以下一个简单的例子。
EditText.OnEditorActionListener
is what you are looking for, the API Documentation can be found here. The action that will be called for the GO button is EditorInfo.IME_ACTION_GO
. I have provided a brief example below.
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;
}
});
这篇关于EditView中执行的单击操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文