AutoCompleteTextView.setAdapter(suggestionInfoAdapter)不显示列表
时间: 2024-06-03 12:11:26 浏览: 13
可能是因为suggestionInfoAdapter中没有数据或者没有正确地实现getView()方法。您可以检查一下suggestionInfoAdapter中的数据是否正常,或者尝试重新实现getView()方法。如果问题仍然存在,您可以提供更多的代码和上下文,以便我能够更好地帮助您解决这个问题。
相关问题
AutoCompleteTextView
AutoCompleteTextView是Android中的一个UI控件,它提供了自动提示的功能。当用户在输入框中输入文字时,AutoCompleteTextView会根据输入的内容自动显示匹配的选项供用户选择。
下面是一个使用AutoCompleteTextView的示例代码:
```java
AutoCompleteTextView autoCompleteTextView = findViewById(R.id.autoCompleteTextView);
String[] options = {"Apple", "Banana", "Cherry", "Durian", "Elderberry"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_dropdown_item_1line, options);
autoCompleteTextView.setAdapter(adapter);
```
在这个示例中,我们首先通过findViewById方法获取到AutoCompleteTextView的实例。然后,我们创建了一个包含一些选项的字符串数组options。接下来,我们创建了一个ArrayAdapter,并将其与AutoCompleteTextView关联起来。最后,我们调用setAdapter方法将适配器设置给AutoCompleteTextView。
这样,当用户在输入框中输入文字时,AutoCompleteTextView会根据输入的内容自动显示匹配的选项供用户选择。
autoCompleteTextView不允许选择
要防止AutoCompleteTextView的选择,您可以使用以下代码:
```
AutoCompleteTextView autoCompleteTextView = findViewById(R.id.autoCompleteTextView);
autoCompleteTextView.setEnabled(false);
autoCompleteTextView.setFocusable(false);
autoCompleteTextView.setClickable(false);
```
这将禁用AutoCompleteTextView的选择功能,并且不允许用户编辑或点击它。如果您需要重新启用它们,只需将`setEnabled`、`setFocusable`和`setClickable`方法的参数设置为`true`即可。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)