如何失去的EditText时与QUOT的重点;完成"在软键盘按钮pressed? [英] How to lose the focus of a edittext when "done" button in the soft keyboard is pressed?

查看:143
本文介绍了如何失去的EditText时与QUOT的重点;完成"在软键盘按钮pressed?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有7的EditText框在我的XML。我使用的是OnFocusChangeListener读取的EditText的价值,我使用该值我calculation.I想我的EditText失去其焦点,当我在软keyboard.so点击完成按钮,我可以得到在的EditText的值。

I have 7 edittext boxes in my xml. I'm using the OnFocusChangeListener to read the value from edittext and i'm using that value for my calculation.I want to make my edittext to lose its focus when i click on the done button in the soft keyboard.so that i can get the value in the edittext.

推荐答案

呼叫 clearFocus 的方法来减肥当重点从软键盘点击完成按钮。做到这一点的:

Call clearFocus method of EditText to lose focus when done button is clicked from soft-keyboard. do it as:

editText.setOnEditorActionListener(new OnEditorActionListener() {        
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if(actionId==EditorInfo.IME_ACTION_DONE){
            //Clear focus here from edittext
             editText.clearFocus();
        }
    return false;
    }
});

,并添加安卓imeOptions =actionDone中的EditText XML

and also add android:imeOptions="actionDone" in edittext xml

这篇关于如何失去的EditText时与QUOT的重点;完成"在软键盘按钮pressed?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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