设置imeActionLabel时的EditText输入法动作不

设置imeActionLabel时的EditText输入法动作不

本文介绍了设置imeActionLabel时的EditText输入法动作不灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 imeoptions 的EDITTEXT为 actiongo 。我和我的触发事件,当pressing软键盘输入按钮。

I have an Edittext with imeoptions asactiongo. and I triggered my event when pressing soft keyboard enter button.

mModelId.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
           // if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
            if (actionId == EditorInfo.IME_ACTION_GO) {

                id = mModelId.getText().toString();
                System.out.println("Model id in Edittext:-"+ id);
                Toast.makeText(getActivity(), "You entered "+id, Toast.LENGTH_LONG).show();
                System.out.println("Before Call Volley");
                callVolley();
                handled = true;
            }
            return handled;
        }
    });

一切工作正常,但是当我添加actionlabel进入关键事件在不触发。 mModelId.setImeActionLabel(搜索模式,KeyEvent.KEY code_ENTER); 。可能是什么问题?

推荐答案

试试这个

宣布这样的EditText和OnEditorActionListener()

declare edittext and OnEditorActionListener() like this

mModelId = (EditText) findViewById(R.id.edittext_id);
        mModelId.setImeActionLabel("Search Model", KeyEvent.KEYCODE_ENTER);
        mModelId.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;

            if (actionId == KeyEvent.KEYCODE_ENTER) {

                id = mModelId.getText().toString();
                System.out.println("Model id in Edittext:-"+ id);
                Toast.makeText(getActivity(), "You entered "+id,    Toast.LENGTH_LONG).show();
                System.out.println("Before Call Volley");
                callVolley();
                handled = true;
            }
            return handled;
        }
    });

和使用imeoptions作为actionGo然后revome它,我认为它会覆盖ImeActionLabel
一次尝试这个和回复

and you use imeoptions as actionGo then revome it, i think it override ImeActionLabelonce try this and reply

这篇关于设置imeActionLabel时的EditText输入法动作不灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 17:37