I am new to Android development and I ran into a problem which I find difficult to solve. I am trying to figure out how to use an AutoCompleteTextView
widget properly. I want to create a AutoCompleteTextView
, using XML data from a web service. I managed to get it to work, but I am defenitely not pleased with the output.
I would like to put a HashMap
with id => name pairs into the AutoCompleteTextView and get the id of the clicked item. When I click on the autocomplete filtered set output, I want to populate a list underneath the autocompletion box, which I also managed to get to work.
Done so far:
- autocomplete works well for simple
ArrayList
, all data filtered correct onItemClick
event fires properly after clickparent.getItemAtPosition(position)
returns correctString
representation of the clicked item
The event onItemClick(AdapterView parent, View v, int position, long id)
does not behave as I would like. How can I figure out the unfiltered array position of the clicked item? The position of the filtered one is the one I am not interested in.
Further questions:
- How to handle
HashMaps
orCollections
inAutoCompleteTextView
- How to get the right
itemId
in theonItemClick
event
I did very extensive research on this issue, but did not find any valuable information which would answer my questions.