如何禁用 AutoCompleteTextView 中某些元素的单击事件

Pra*_*tik 5 android autocompletetextview

我正在使用 AutoCompleteTextView (参考:AutoCompleteTextView

我可以获得此视图提供的自动建议列表。

现在我想禁用此视图中的第二个建议。

你能告诉我如何实现它吗?谢谢

waq*_*lam 5

AutoCompleteTextView通过扩展ArrayAdapter覆盖 isEnabled该自定义适配器的方法来定义哪些项目可单击或不可单击,从而为您创建一个自定义数据适配器。

@Override
public boolean isEnabled(int position) {
    // TODO Auto-generated method stub
    return super.isEnabled(position);
}
Run Code Online (Sandbox Code Playgroud)