本文介绍了Android的:如何打开键盘进行编辑时的EditText单击按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是:我有一个外地的EditText是有残疾的焦点。
除了现场的EditText我有输入法两个按钮。所以,我想首先单击按钮时:打开连接时,键盘软,并在现场的EditText编辑文本。我尝试了很多方法用:

my case is: I have one EditText field that is with disabled focus.Beside EditText field I has two buttons for Input methods. So I want when click first button: to open soft keybord and edit text in EditText field. I try many ways with:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);

和对我不起作用。只有打开软键盘方式是:

and doesn't work for me. Only way to open soft keyboard is:

toggleSoftInput(InputMethodManager.SHOW_FORCED,0)

但没有办法从编辑领域的EditText信息。

but there is no way to edit info from EditText field.

愿你建议我如何打开键盘和编辑文本一些EditText上时,点击按钮。
非常感谢!

May you suggest me how to open keyboard and edit text for some EditText when click button.Thanks a lot!

编辑:

因此​​,EditText上不可作为焦点为默认值。当我点击键盘按钮 - 应该成为焦点,然后告诉我软键盘输入文字和出现的EditText。插入另一种方法是不需要键盘的A-B-C键。这将是类似于莫尔斯code输入 - 触摸并按住A-B-C键:)我会尽量建议例如,在我的情况下实现。谢谢你们:)

So, EditText is not focusable be default. When I click Keyboard button - should be focusable, then show me soft keyboard to enter text and appear in EditText. Other method to insert is A-B-C button which not required keyboard. It will be something like Morse code input - touch and hold A-B-C button :) I'll try suggested example to implement in my case. Thank you guys :)

推荐答案

谢谢你们的帮助:)我用你给我的所有建议,搜索和测试许多其他脚本,最后我的code这是工作:)

Thanks guys for your help :) I used all suggestions that you give me, searching and testing a lots of other scripts and finally my code it's work :)

下面是我最后的code:

Here is my final code:

InputEditText = (EditText) findViewById(R.id.InputText);

public void InputData() {

        /* Keyboard Button Action */
        KeyboardButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                Log.v(TAG, "On Keyboard Button click event!");

                InputEditText.requestFocus();
                InputEditText.setFocusableInTouchMode(true);

                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(InputEditText, InputMethodManager.SHOW_FORCED);

            }

        });

}

这可能是有用的人:)
谢谢!

It may be usefully for someone :)Thank you!

这篇关于Android的:如何打开键盘进行编辑时的EditText单击按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 18:02
查看更多