gpt4 book ai didi

android - MultiAutoCompleteTextView 不工作 OnItemSelectedListener

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:49 26 4
gpt4 key购买 nike

ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(Application.getContext(), R.layout.report_add_list_item, ListUtil.asStringList(ContactServiceUtil.getContacts()));
multiAutoCompleteContacts = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteGuests);
multiAutoCompleteContacts.setAdapter(adapter1);
multiAutoCompleteContacts.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
multiAutoCompleteContacts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
System.out.println("click");
}

public void onNothingSelected(AdapterView<?> adapterView) {
return;
}
});

我没有进入 onItemSelected。我需要按位置选择我的列表中的哪一个,以获取 ID。

最佳答案

OnItemSelectedListener 永远不会被 AutoCompleteTextView(或 MultiAutoCompleteTextView)触发。改为使用 OnItemClickListener:

setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Object item = parent.getItemAtPosition(position);
}
});

关于android - MultiAutoCompleteTextView 不工作 OnItemSelectedListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7725419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com