Android ListView标头中的AutocompleteTextView工作不正常
由于我有了新的信息,重复了一些修改后的问题 因此,从一开始: 我用ArrayAdapter填充了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,
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:在下拉列表出现后立即执行一些其他操作
步骤:
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();
}