简体   繁体   English

我如何知道Android中AutoCompleteTextView所选项目的位置?

[英]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.

相关问题 Android AutoCompleteTextView:获取项目位置 - Android AutoCompleteTextView: get item position 如何在Android中加速AutocompleteTextView? - How can I speed up an AutocompleteTextView in Android? 如何从自动完成文本视图中删除以前选择的项目 - How to remove previous selected item from autocompletetextview 我如何知道在Android Studio中选择了哪个单选按钮 - How can I know which radio button is selected in Android studio Android AutoCompleteTextView如何忽略多余的空格 - Android AutoCompleteTextView how can I ignore extra spaces 如何通过按下按钮重置 MDC 微调器(AutoCompleteTextview/ExposedDropdownMenu)中的选定项目 - How to reset selected item in MDC spinner (AutoCompleteTextview/ ExposedDropdownMenu) with press of a button 在AutoCompleteTextView的CustomAdapter中访问所选项目的值 - accessing values of selected item in AutoCompleteTextView's CustomAdapter 如果未选择 AutoCompleteTextView 中的任何项目,则显示错误 - Displaying Error if no item from a AutoCompleteTextView is selected Android:如何制作AutoCompleteTextView来传递网站中的文字并向我显示结果 - Android:How can i make an AutoCompleteTextView to pass the text from a website and show me the results 如何在Android的另一个班级中访问选定的列表项 - How can i gain access to the selected list item in another class in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM