[英]How can I know the position of the selected item of an AutoCompleteTextView in Android?
我有一個AutoCompleteTextView。 我通過擴展CursorAdapter來設置其適配器。 從下拉菜單中選擇一個選項后,我想知道所選項目的位置。 至少,我想要一個用於在Sqlite中獲取更多數據的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.