I need to search an arrayadapter for a value and position that row at the top of the screen.
I have a simple custom array adapter that is linked to a cursor. The cursor finds 1000 records on average. There is a point in the app that the user enters a piece of information. From that I can find the item in the database using a quick database lookup.
I then know that the item is in my arrayadapter. I need to find the position in the adapter and move that item to the top of the screen.
How can I find where in the adapter this value is? I know the data exists in the found set, but how do I find this value in that found set and put it at the top of the screen?
I know how to position the screen once I find it in the adapter, just not an efficient way to find it. I am currently looping through the array until I find the correct row.
Well as you said you’re looping through the array in linear fashion. You could build a HashMap which maps keys to an int of your position – so lookups are done in constant time.