繁体   English   中英

EditText没有显示虚拟键盘

[英]EditText is not showing virtual keyboard

我创建了一个带有editText的动态屏幕..但是单击后未显示虚拟键盘。我添加了以下代码..但仍然有效。

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

而且这也起作用

InputMethodManager im = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

im.showSoftInput(edittext,0);

我的代码在这里...

runOnUiThread(new Runnable() {
            public void run() {
                LinearLayout findViewById = (LinearLayout) findViewById(R.id.dynamicInputs);
                //TextView textView = (TextView) findViewById(R.id.name);
                TextView textView = new TextView(Activity_UserInput.this);
                textView.setText("   " + map.get(KEY_NAME) + " :");
                textView.setTextColor(Color.BLACK);
                textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 17);
                //textView.setLayoutParams(new LayoutParams(Layout.DIR_LEFT_TO_RIGHT, Gravity.CENTER_VERTICAL));

                findViewById.addView(textView);

                EditText editText = new EditText(Activity_UserInput.this);
                editText.setText("");
                //editText.setInputType(InputType.TYPE_CLASS_NUMBER);  

                findViewById.addView(editText);

            }

让我尝试一下,我认为您需要将重点放在editText之类的..

    editText.setFocusableInTouchMode(true);
    editText.requestFocus();

我不确定,但请尝试一下,让我知道它是否有效。

从XML移除

Android:isFocusable="false"

如果没有发布您的XML,请

顺便说一句

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)

是正确的

尝试这个

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM