android - 无法打开自动完成文本的软键盘

标签 android keyboard autocompletetextview

在 Eclipse 中测试自动完成文本控件时,我无法让软键盘显示在我的三星手机上。我点击以物理触摸自动完成文本控件以调出键盘。不允许显示软键盘的 AutoCompleteText 控件有什么不同之处。下面是我在 Activity 的 onCreate 方法中的代码。我将不胜感激任何帮助。

    autoComplete = (AutoCompleteTextView) findViewById(R.id.suggest);
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(autoComplete, InputMethodManager.SHOW_FORCED);
        if (imm != null){
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
              } 
    //    imm.toggleSoftInput(0, 0);

        autoComplete.addTextChangedListener(new TextWatcher(){

            public void afterTextChanged(Editable editable) {
                // TODO Auto-generated method stub

            }

            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // TODO Auto-generated method stub

            }

            public void onTextChanged(CharSequence s, int start, int before, int count) {
                String newText = s.toString();
                int len = newText.length();
           //     Toast.makeText(getApplicationContext(), "Text changed count = " + String.valueOf(len), Toast.LENGTH_LONG).show();
                if(len > 1)
                    new getData().execute(newText);
            }

        });

最佳答案

试试这个

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

这将强制键盘显示

关于android - 无法打开自动完成文本的软键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589439/

相关文章:

android - 自动完成 TextView 错误 : IllegalStateException: The content of the adapter has changed but ListView did not receive a notification

android - 在 android 中使用 txt 文件数据显示 AutoCompleteTextView

java - AutocompleteTextview 中的 Android Listview 没有响应

android - 如何在 Android 上创建文本文件并将数据插入该文件

android - 改变方向的工作流程

javascript - Jquery 在 Enter Key Press 上选择 NEXT 文本字段

c - 如何在c中的32位操作系统中制作scanf()类型的函数?

android - 找不到Gradle DSL方法:testCompile()

android - 在 Unity Android/iOS 中高效存储大量图像

ios - 为什么 Swift 4 显示键盘时 stackview 会在 3 秒后消失?