[英]How can I know the position of the selected item of an AutoCompleteTextView in Android?
I have an AutoCompleteTextView. 我有一个AutoCompleteTextView。 I set its adapter by extending a CursorAdapter.
我通过扩展CursorAdapter来设置其适配器。 After selecting an option from the dropdown, I like to know the position of the item, or the item, that was selected.
从下拉菜单中选择一个选项后,我想知道所选项目的位置。 At least, I want an id for fetching more data in Sqlite.
至少,我想要一个用于在Sqlite中获取更多数据的ID。 How can I do that?
我怎样才能做到这一点?
Simply override the AutoCompleteTextView's OnItemClickedListener to find the position
of the item in the dropdown list or the SQLite row id
: 只需覆盖AutoCompleteTextView的OnItemClickedListener即可在下拉列表或SQLite行
id
找到项目的position
:
autoCompleteTextView.setOnItemClickedListener(new OnItemSelectedListener() {
@Override
public void onItemClicked(AdapterView<?> parent, View view, int position, long id) {
// Do whatever you want with the position or id
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.