Android ListView标头中的AutocompleteTextView工作不正常

Android ListView标头中的AutocompleteTextView工作不正常,android,autocompletetextview,Android,Autocompletetextview,由于我有了新的信息,重复了一些修改后的问题 因此,从一开始: 我用ArrayAdapter填充了AutoCompleteTextView: AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) header.findViewById(R.id.auto_complete_text_view); autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,

由于我有了新的信息,重复了一些修改后的问题

因此,从一开始: 我用ArrayAdapter填充了AutoCompleteTextView:

AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) header.findViewById(R.id.auto_complete_text_view);
autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList));
结果:查看行为保持不变

结果:我认为这个决定不适合我的问题,所以没有尝试。至少现在是这样

===============================================

Idea#4:在下拉列表出现后立即执行一些其他操作 步骤:

  • 开始在我的AutoCompleteTextView中键入一些内容–如前所述 在上面,只键入一个符号,出现下拉列表
  • 其他区域的触摸屏(非下拉列表)–列表 消失
  • 再次单击AutocompleteTextView的输入字段并继续 键入–可以再键入一个符号,出现下拉列表
  • 重复上述步骤,我可以键入较大的内容

    ===============================================

    最后一条:当我在AutoCompleteTextView中键入内容时,在Logcat中注意到许多以下消息:

    getTextBeforeCursor on inactive InputConnection
    
    已发现一些相关问题,例如:

    解决方案:

    @Override
    protected void onPause() {
    
        // hide the keyboard in order to avoid getTextBeforeCursor on inactive InputConnection
        InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    
        inputMethodManager.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    
        super.onPause();
    }
    
    结果:查看行为保持不变


    我迷路了。

    有什么问题:?顺便问一下,使用ACTV作为列表视图标题的原因是什么?@pskink试图在模拟设备上运行该代码段:java.lang.security异常:权限拒绝:打开提供商com.android.providers.contacts.contacts Provider2需要android.Permission.READ\u contacts或android.Permission.WRITE\u contacts关于页眉:页眉中不仅有一个ACTV,还有很多视图,因为活动本质上是一个带有页眉和页脚的列表视图。我需要所有的滚动条。我有一个选择:写一些非CrollableListView或使用标题。我选择了标题。到目前为止一切正常。添加android.permission.READ_CONTACTS permission,我以CONTACTS为例,在列表视图中显示任何内容,而不填充任何数据库。这是我做的第一件事。由于某种原因,它没有帮助
    String[] array = {“one”, “two”, “three”, “four”}
    autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, array));
    
    AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.auto_complete_text_view);
    autoCompleteTextView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, arrayList));
    
    android:descendantFocusability="afterDescendants"
    
    getTextBeforeCursor on inactive InputConnection
    
    @Override
    protected void onPause() {
    
        // hide the keyboard in order to avoid getTextBeforeCursor on inactive InputConnection
        InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    
        inputMethodManager.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    
        super.onPause();
    }