当编辑文本完成正在编辑了解文本、编辑、正在编辑

2023-09-12 08:30:42 作者:屋顶上的小猫咪

我如何知道我的编辑文本完成正在编辑?当用户选择下一个框,或presses软键盘上的完成按钮,就像

How do I know when my edit text is done being edited? Like when the user selects the next box, or presses the done button on the soft keyboard.

我想知道这个,所以我可以钳制输入。它看起来像文本观察者的afterTextChanged发生,如果输入的字符之后。我需要做一些计算和输入,所以我想避免这样做的计算,如果输入的字符之后。

I want to know this so I can clamp the input. It looks like text watcher's afterTextChanged happens after each character is entered. I need to do some calculations with the input, so I would like to avoid doing the calculation after each character is entered.

感谢

推荐答案

通过使用这样的事情

 meditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {

                yourcalc();

                return true;
            }
            return false;
        }
    });