更改的“完成”按钮就行动虚拟键盘的Andr​​oid [英] Change Action of 'Done' Button on Virtual Keyboard Android

查看:179
本文介绍了更改的“完成”按钮就行动虚拟键盘的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

清一色我看了一下有关这个主题的其他问题,并发现了根据Android开发网站:操作时,通常意味着输入法将被关闭,操作键执行完成我的问题是的我怎么编辑完成按钮的作用,使其所以它调用我的方法之一,而不是关闭输入法的?
谢谢你的时间。

All- I looked at other questions relating to this topic and found out that according to the android development website: "the action key performs a "done" operation, typically meaning the IME will be closed." My question is how do I edit the action of the done button to make it so it calls one of my methods instead of closing the IME? Thanks for your time.

推荐答案

最好的方式

示例处理输入的按键事件

Example for handling Enter key event

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    txt = (EditText)findViewById(R.id.txt);
    txt.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) 
         {
           if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) 
           {
               Log.d(TAG, "enter_key_called");
           }
            return false;
        }
    });
}

这篇关于更改的“完成”按钮就行动虚拟键盘的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆